oer

package
v0.0.0-...-add61a3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEOF              = errors.New("EOF")
	ErrInvalidTimestamp = errors.New("invalid timestamp")
)

Functions

func Marshal

func Marshal(enc *Encoder, m Marshaler) error

func ParseTimestamp

func ParseTimestamp(s string) (time.Time, error)

func ParseTimestampFixed

func ParseTimestampFixed(b []byte) (time.Time, error)

func Unmarshal

func Unmarshal(b interface{}, m Unmarshaler) error

Types

type Decoder

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

Decoder wraps a buffered reader and reads from it using OER rules. This decoder is NOT safe for concurrent use as it makes no sense for it to be. The implementation follows the OER notes (https://interledger.org/rfcs/0030-notes-on-oer-encoding/). All the functions that return a slice of bytes allocate a new slice for every call. This is because these values might be processed further, but the original underlying array could change.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) ReadAll

func (d *Decoder) ReadAll() []byte

func (*Decoder) ReadOctetString

func (d *Decoder) ReadOctetString(l int) ([]byte, error)

ReadOctetString reads a fixed length octet string

func (*Decoder) ReadOctetStringTo

func (d *Decoder) ReadOctetStringTo(l int, m []byte) error

func (*Decoder) ReadTimestamp

func (d *Decoder) ReadTimestamp() (time.Time, error)

func (*Decoder) ReadTimestampFixed

func (d *Decoder) ReadTimestampFixed() (time.Time, error)

ReadTimestampFixed reads a Interledger OER compatible timestamp and converts it into a Golang timestamp

func (*Decoder) ReadUInt16

func (d *Decoder) ReadUInt16() (uint16, error)

ReadUInt16 reads an unsigned 16 bit integer

func (*Decoder) ReadUInt32

func (d *Decoder) ReadUInt32() (uint32, error)

ReadUInt32 reads an unsigned 32 bit integer

func (*Decoder) ReadUInt64

func (d *Decoder) ReadUInt64() (uint64, error)

ReadUInt64 reads an unsigned 64 bit integer

func (*Decoder) ReadUInt8

func (d *Decoder) ReadUInt8() (uint8, error)

ReadUInt8 reads an unsigned 8 bit integer

func (*Decoder) ReadVarOctetString

func (d *Decoder) ReadVarOctetString() ([]byte, error)

ReadVarOctetString reads an octet string which has a length prefix attached

func (*Decoder) ReadVarString

func (d *Decoder) ReadVarString() (string, error)

ReadVarString reads an UTF-8 encoded string

func (*Decoder) ReadVarUInt

func (d *Decoder) ReadVarUInt() (*big.Int, error)

type Encoder

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

Encoder wraps a Writer and writes to it using OER rules. This encoder is NOT safe for concurrent use as it makes no sense for it to be. The implementation follows the OER notes (https://interledger.org/rfcs/0030-notes-on-oer-encoding/). All the values of slices passed in as arguments are copied to prevent them from changing before being written to the underlying Writer.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) WriteOctetString

func (e *Encoder) WriteOctetString(d []byte) error

WriteOctetString writes a fixed length octet string

func (*Encoder) WriteTimestamp

func (e *Encoder) WriteTimestamp(t time.Time) error

func (*Encoder) WriteTimestampFixed

func (e *Encoder) WriteTimestampFixed(t time.Time) error

WriteTimestampFixed writes a GeneralizedTime formatted timestamp

func (*Encoder) WriteUInt16

func (e *Encoder) WriteUInt16(v uint16) error

WriteUInt16 writes an unsigned 16 bit integer

func (*Encoder) WriteUInt32

func (e *Encoder) WriteUInt32(v uint32) error

WriteUInt32 writes an unsigned 32 bit integer

func (*Encoder) WriteUInt64

func (e *Encoder) WriteUInt64(v uint64) error

WriteUInt64 writes an unsigned 64 bit integer

func (*Encoder) WriteUInt8

func (e *Encoder) WriteUInt8(v uint8) error

WriteUInt8 writes an unsigned 8 bit integer

func (*Encoder) WriteVarOctetString

func (e *Encoder) WriteVarOctetString(d []byte) error

WriteVarOctetString writes an octet string with a length prefix

func (*Encoder) WriteVarString

func (e *Encoder) WriteVarString(s string) error

WriteVarString writes an UTF-8 encoded string

func (*Encoder) WriteVarUInt

func (e *Encoder) WriteVarUInt(v *big.Int) error

WriteVarUInt writes an unsigned integer of arbitrary size

type Marshaler

type Marshaler interface {
	MarshalOER(*Encoder) error
}

type Unmarshaler

type Unmarshaler interface {
	UnmarshalOER(*Decoder) error
}

Jump to

Keyboard shortcuts

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