torrent: github.com/anacrolix/torrent/bencode Index | Files

package bencode

import "github.com/anacrolix/torrent/bencode"

Index

Package Files

api.go bytes.go decode.go encode.go misc.go scanner.go tags.go

func Marshal Uses

func Marshal(v interface{}) ([]byte, error)

Marshal the value 'v' to the bencode form, return the result as []byte and an error if any.

func MustMarshal Uses

func MustMarshal(v interface{}) []byte

func Unmarshal Uses

func Unmarshal(data []byte, v interface{}) (err error)

Unmarshal the bencode value in the 'data' to a value pointed by the 'v' pointer, return a non-nil error if any.

type Bytes Uses

type Bytes []byte

func (Bytes) MarshalBencode Uses

func (me Bytes) MarshalBencode() ([]byte, error)

func (*Bytes) UnmarshalBencode Uses

func (me *Bytes) UnmarshalBencode(b []byte) error

type Decoder Uses

type Decoder struct {

    // Sum of bytes used to Decode values.
    Offset int64
    // contains filtered or unexported fields
}

func NewDecoder Uses

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Decode Uses

func (d *Decoder) Decode(v interface{}) (err error)

type Encoder Uses

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

func NewEncoder Uses

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) Encode Uses

func (e *Encoder) Encode(v interface{}) (err error)

type ErrUnusedTrailingBytes Uses

type ErrUnusedTrailingBytes struct {
    NumUnusedBytes int
}

func (ErrUnusedTrailingBytes) Error Uses

func (me ErrUnusedTrailingBytes) Error() string

type MarshalTypeError Uses

type MarshalTypeError struct {
    Type reflect.Type
}

In case if marshaler cannot encode a type, it will return this error. Typical example of such type is float32/float64 which has no bencode representation.

func (*MarshalTypeError) Error Uses

func (e *MarshalTypeError) Error() string

type Marshaler Uses

type Marshaler interface {
    MarshalBencode() ([]byte, error)
}

Any type which implements this interface, will be marshaled using the specified method.

type MarshalerError Uses

type MarshalerError struct {
    Type reflect.Type
    Err  error
}

A non-nil error was returned after calling MarshalBencode on a type which implements the Marshaler interface.

func (*MarshalerError) Error Uses

func (e *MarshalerError) Error() string

type SyntaxError Uses

type SyntaxError struct {
    Offset int64 // location of the error
    What   error // error description
}

Malformed bencode input, unmarshaler failed to parse it.

func (*SyntaxError) Error Uses

func (e *SyntaxError) Error() string

type UnmarshalFieldError Uses

type UnmarshalFieldError struct {
    Key   string
    Type  reflect.Type
    Field reflect.StructField
}

Unmarshaler tried to write to an unexported (therefore unwritable) field.

func (*UnmarshalFieldError) Error Uses

func (e *UnmarshalFieldError) Error() string

type UnmarshalInvalidArgError Uses

type UnmarshalInvalidArgError struct {
    Type reflect.Type
}

Unmarshal argument must be a non-nil value of some pointer type.

func (*UnmarshalInvalidArgError) Error Uses

func (e *UnmarshalInvalidArgError) Error() string

type UnmarshalTypeError Uses

type UnmarshalTypeError struct {
    Value string
    Type  reflect.Type
}

Unmarshaler spotted a value that was not appropriate for a given Go value.

func (*UnmarshalTypeError) Error Uses

func (e *UnmarshalTypeError) Error() string

type Unmarshaler Uses

type Unmarshaler interface {
    UnmarshalBencode([]byte) error
}

Any type which implements this interface, will be unmarshaled using the specified method.

type UnmarshalerError Uses

type UnmarshalerError struct {
    Type reflect.Type
    Err  error
}

A non-nil error was returned after calling UnmarshalBencode on a type which implements the Unmarshaler interface.

func (*UnmarshalerError) Error Uses

func (e *UnmarshalerError) Error() string

Package bencode imports 14 packages (graph) and is imported by 94 packages. Updated 2020-02-20. Refresh now. Tools for package owners.