Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder reads and decodes bencode values from an input stream.
func NewDecoder ¶
NewDecoder returns a new decoder that reads from r.
func (*Decoder) BytesParsed ¶
BytesParsed returns the number of bytes that have actually been parsed
func (*Decoder) Decode ¶
Decode reads the next bencoded value from its input and stores it in the value pointed to by v.
func (*Decoder) DisallowUnknownFields ¶
func (dec *Decoder) DisallowUnknownFields()
DisallowUnknownFields causes the Decoder to return an error when the destination is a struct and the input contains object keys which do not match any non-ignored, exported fields in the destination.
func (*Decoder) DisallowUnorderedKeys ¶
func (dec *Decoder) DisallowUnorderedKeys()
DisallowUnorderedKeys will cause the decoder to fail when encountering unordered keys. The default is to not fail.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder writes bencoded objects to an output stream.
func NewEncoder ¶
NewEncoder returns a new encoder that writes to w.
func (*Encoder) Encode ¶
Encode writes the bencoded data of val to its output stream. If an encountered value implements the Marshaler interface, its MarshalBencode method is called to produce the bencode output for this value. If no MarshalBencode method is present but the value implements encoding.TextMarshaler instead, its MarshalText method is called, which encodes the result as a bencode string. See the documentation for Decode about the conversion of Go values to bencoded data.
type InvalidUnmarshalError ¶
An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)
func (*InvalidUnmarshalError) Error ¶
func (e *InvalidUnmarshalError) Error() string
type Marshaler ¶
Marshaler is the interface implemented by types that can marshal themselves into valid bencode.
type RawMessage ¶
type RawMessage []byte
RawMessage is a raw encoded bencode value. It implements Marshaler and Unmarshaler and can be used to delay bencode decoding or precompute a bencoding.
func (RawMessage) MarshalBencode ¶
func (m RawMessage) MarshalBencode() ([]byte, error)
MarshalBencode returns m as the bencoding of m.
func (*RawMessage) UnmarshalBencode ¶
func (m *RawMessage) UnmarshalBencode(data []byte) error
UnmarshalBencode sets *m to a copy of data.
type SyntaxError ¶
type SyntaxError struct { Offset int64 // error occurred after reading Offset bytes // contains filtered or unexported fields }
A SyntaxError is a description of a bencode syntax error.
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
type UnmarshalTypeError ¶
type UnmarshalTypeError struct { Value string // description of bencode value - "integer", "string", "list", "dict" Type reflect.Type // type of Go value it could not be assigned to Offset int64 // error occurred after reading Offset bytes Struct string // name of the struct type containing the field Field string // name of the field holding the Go value }
An UnmarshalTypeError describes a bencode value that was not appropriate for a value of a specific Go type.
func (*UnmarshalTypeError) Error ¶
func (e *UnmarshalTypeError) Error() string
type Unmarshaler ¶
Unmarshaler is the interface implemented by types that can unmarshal a bencode description of themselves.
type UnsupportedTypeError ¶
An UnsupportedTypeError is returned by Marshal when attempting to encode an unsupported value type.
func (*UnsupportedTypeError) Error ¶
func (e *UnsupportedTypeError) Error() string