bert

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2021 License: MIT Imports: 9 Imported by: 3

README

About

The gobert project is a Go library implementing the BERT serialization and RPC protocol.

Status

I, Seth Klein, don't use this library. I updated it to Go 1 for someone in #go-nuts and the original maintainer declared it dead so I figured I'd do the basics and handle bug reports and pull requests. As of February, 2013, the last post to the BERT mailing list was nearly two years ago so unless this gets serious interest, I'm not going to sink oodles of effort into figuring out what full BERT compliance is or whether this library implements it. (The original author implies that it doesn't.) Feel free to report bugs and make pull requests, though.

Reporting Bugs

Bugs may be reported at https://github.com/sethwklein/gobert/issues or via email or Twitter to the maintainer contact below.

Maintainer Contact

Seth W. Klein sk@sethwklein.net @sethwklein

History

The gobert project was started by Joshua Peek in 2009. In 2013 he confirmed that he was no longer maintaining it, and Seth W. Klein assumed maintenance.

Documentation

Overview

Package bert implements the BERT serialization and RPC protocol. See http://bert-rpc.org/

Index

Examples

Constants

View Source
const (
	VersionTag     = 131
	SmallIntTag    = 97
	IntTag         = 98
	SmallBignumTag = 110
	LargeBignumTag = 111
	FloatTag       = 99
	AtomTag        = 100
	SmallTupleTag  = 104
	LargeTupleTag  = 105
	NilTag         = 106
	StringTag      = 107
	ListTag        = 108
	BinTag         = 109
	BitTag         = 77
)
View Source
const (
	BertAtom  = Atom("bert")
	NilAtom   = Atom("nil")
	TrueAtom  = Atom("true")
	FalseAtom = Atom("false")
)

Variables

View Source
var ErrBadMagic error = errors.New("bad magic")
View Source
var ErrUintType error = errors.New("Unsupported value type uint.")
View Source
var ErrUnknownType error = errors.New("unknown type")

Functions

func Encode

func Encode(val interface{}) ([]byte, error)

Encode encodes val and returns it or an error.

func EncodeTo

func EncodeTo(w io.Writer, val interface{}) (err error)

EncodeTo encodes val and writes it to w, returning any error.

func Marshal

func Marshal(w io.Writer, val interface{}) error

Marshal is an alias for EncodeTo.

func MarshalResponse

func MarshalResponse(w io.Writer, val interface{}) (err error)

MarshalResponse encodes val into a BURP Response struct and writes it to w, returning any error.

func Unmarshal

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

Unmarshal decodes a value from data, stores it in val, and returns any error encountered.

func UnmarshalFrom

func UnmarshalFrom(r io.Reader, val interface{}) (err error)

UnmarshalFrom decodes a value from r, stores it in val, and returns any error encountered.

Types

type Atom

type Atom string

type Bitstring

type Bitstring struct {
	Bytes []byte
	Bits  uint8
}

type List

type List struct {
	Items []Term
}

type Request

type Request struct {
	Kind      Atom
	Module    Atom
	Function  Atom
	Arguments []Term
}

func UnmarshalRequest

func UnmarshalRequest(r io.Reader) (Request, error)

UnmarshalRequest decodes a BURP from r and returns it as a Request.

type Term

type Term interface{}

func Decode

func Decode(data []byte) (Term, error)

Decode decodes a Term from data and returns it or an error.

Example
i, err := Decode([]byte{131, 97, 42})
if err != nil {
	fmt.Println(err)
}
fmt.Printf("%#v\n", i)
s, err := Decode([]byte{131, 107, 0, 3, 102, 111, 111})
if err != nil {
	fmt.Println(err)
}
fmt.Printf("%#v\n", s)
a, err := Decode([]byte{131, 104, 1, 100, 0, 3, 102, 111, 111})
if err != nil {
	fmt.Println(err)
}
fmt.Printf("%#v\n", a)
Output:

42
"foo"
[]bert.Term{"foo"}

func DecodeFrom

func DecodeFrom(r io.Reader) (Term, error)

DecodeFrom decodes a Term from r and returns it or an error.

Notes

Bugs

  • Full BERT specification compliance is still in progress.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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