bencode

package module
v0.0.0-...-d267724 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 6 Imported by: 0

README

Go Reference build coverage Go Report Card

bencode

Encoding and decoding of values as defined in BEP 3.

Documentation

Overview

Package bencode implements encoding and decoding of values as defined in BEP 3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v any) (string, error)

Marshal

func Unmarshal

func Unmarshal(s string, v any) error

Unmarshal

Types

type Decoder

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

Decoder

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder

func (*Decoder) Decode

func (d *Decoder) Decode(v any) error

Decode

type Encoder

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

Encoder

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder

func (*Encoder) Encode

func (e *Encoder) Encode(v any) error

Encode

type Marshaler

type Marshaler interface {
	MarshalBEncoding() (string, error)
}

Marshaler

type SyntaxError

type SyntaxError struct {
	Offset int64 // error occurred after read Offset byts
	// contains filtered or unexported fields
}

A SyntaxError is a description of a bencoding syntax error.

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

type UnmarshalTypeError

type UnmarshalTypeError struct {
	Value string       // description of bencoding value
	Type  reflect.Type // type of Go value if could not be assigned to
}

An UnmarshalTypeError describes a bencoding value that was not appropriate for a value of a specific Go type.

func (*UnmarshalTypeError) Error

func (e *UnmarshalTypeError) Error() string

type Unmarshaler

type Unmarshaler interface {
	UnmarshalBEncoding(string) error
}

Unmarshaler

type UnsupportedTypeError

type UnsupportedTypeError struct {
	Type reflect.Type
}

An UnsupportedTypeError is returned by Marshal when attempting to encode an unsupported value type.

func (*UnsupportedTypeError) Error

func (e *UnsupportedTypeError) Error() string

Jump to

Keyboard shortcuts

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