bencoding

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dictionary

type Dictionary struct {
	// contains filtered or unexported fields
}

Dictionary holds the encoded key value pairs

func NewDictionary

func NewDictionary() *Dictionary

NewDictionary creates and returns a new initialized Dictionary.

func (*Dictionary) Any

func (d *Dictionary) Any(key string, v interface{}) error

Any tries to write given type to dictionary. It returns an error if it is unabled to write the desired type to the dictionary. Any performs far worse than specific type encoding functions and should be avoided when possible.

func (*Dictionary) BytesliceSlice

func (d *Dictionary) BytesliceSlice(key string, slice [][]byte)

BytesliceSlice writes a list of form byte slice slice ([][]byte) to the dictionary.

func (*Dictionary) Dictionary

func (d *Dictionary) Dictionary(key string, v string)

Dictionary writes an encoded dictionary to the dictionary.

func (*Dictionary) EndDictionary

func (d *Dictionary) EndDictionary()

EndDictionary finishes the embedded dictionary. StartDictionary() should be called before this.

func (*Dictionary) Get

func (d *Dictionary) Get() string

Get returns the encoded dictionary as a string. The dictionary should not be used after.

func (*Dictionary) GetBytes

func (d *Dictionary) GetBytes() []byte

Get returns the encoded dictionary as a byte slice. The dictionary should not be used after.

func (*Dictionary) Int64

func (d *Dictionary) Int64(key string, v int64)

Int64 writes an int64 to the dictionary.

func (*Dictionary) Reset

func (d *Dictionary) Reset()

Reset resets the Dictionary's underlying byte slice.

func (*Dictionary) StartDictionary

func (d *Dictionary) StartDictionary(key string)

StartDictionary begins an embedded dictionary with the given string key. EndDictionary() must be called to complete the embedded dictionary before Get() is called.

func (*Dictionary) StartDictionaryBytes

func (d *Dictionary) StartDictionaryBytes(key []byte)

StartDictionary begins an embedded dictionary with the given byte slice key. EndDictionary() must be called to complete the embedded dictionary before Get() is called.

func (*Dictionary) String

func (d *Dictionary) String(key string, v string)

String writes a string to the dictionary.

func (*Dictionary) StringBytes

func (d *Dictionary) StringBytes(key string, v []byte)

StringBytes writes a byte slice to the dictionary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL