bencode

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

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNum         = errors.New("expect num")
	ErrColon       = errors.New("expect colon")
	ErrExpCharI    = errors.New("expect char i")
	ErrExpCharE    = errors.New("expect char e")
	ErrType        = errors.New("wrong type")
	ErrWriteFailed = errors.New("write failed")
	ErrReadFailed  = errors.New("read failed")
)

Functions

func DecodeInt

func DecodeInt(r io.Reader) (val int, err error)

func DecodeString

func DecodeString(r io.Reader) (val string, err error)

func EncodeInt

func EncodeInt(w io.Writer, val int) (int, error)

func EncodeString

func EncodeString(w io.Writer, val string) (int, error)

Types

type BObject

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

func Parse

func Parse(r io.Reader) (*BObject, error)

func (*BObject) Bencode

func (o *BObject) Bencode(w io.Writer) int

func (*BObject) Dict

func (o *BObject) Dict() (map[string]*BObject, error)

func (*BObject) Int

func (o *BObject) Int() (int, error)

func (*BObject) List

func (o *BObject) List() ([]*BObject, error)

func (*BObject) Str

func (o *BObject) Str() (string, error)

type BType

type BType uint8
const (
	BSTR  BType = 0x01
	BINT  BType = 0x02
	BLIST BType = 0x03
	BDICT BType = 0x04
)

type BValue

type BValue any

Jump to

Keyboard shortcuts

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