Documentation ¶
Index ¶
- Variables
- func Marshal(enc *Encoder, m Marshaler) error
- func ParseTimestamp(s string) (time.Time, error)
- func ParseTimestampFixed(b []byte) (time.Time, error)
- func Unmarshal(b interface{}, m Unmarshaler) error
- type Decoder
- func (d *Decoder) ReadAll() []byte
- func (d *Decoder) ReadOctetString(l int) ([]byte, error)
- func (d *Decoder) ReadOctetStringTo(l int, m []byte) error
- func (d *Decoder) ReadTimestamp() (time.Time, error)
- func (d *Decoder) ReadTimestampFixed() (time.Time, error)
- func (d *Decoder) ReadUInt16() (uint16, error)
- func (d *Decoder) ReadUInt32() (uint32, error)
- func (d *Decoder) ReadUInt64() (uint64, error)
- func (d *Decoder) ReadUInt8() (uint8, error)
- func (d *Decoder) ReadVarOctetString() ([]byte, error)
- func (d *Decoder) ReadVarString() (string, error)
- func (d *Decoder) ReadVarUInt() (*big.Int, error)
- type Encoder
- func (e *Encoder) WriteOctetString(d []byte) error
- func (e *Encoder) WriteTimestamp(t time.Time) error
- func (e *Encoder) WriteTimestampFixed(t time.Time) error
- func (e *Encoder) WriteUInt16(v uint16) error
- func (e *Encoder) WriteUInt32(v uint32) error
- func (e *Encoder) WriteUInt64(v uint64) error
- func (e *Encoder) WriteUInt8(v uint8) error
- func (e *Encoder) WriteVarOctetString(d []byte) error
- func (e *Encoder) WriteVarString(s string) error
- func (e *Encoder) WriteVarUInt(v *big.Int) error
- type Marshaler
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
var ( ErrEOF = errors.New("EOF") ErrInvalidTimestamp = errors.New("invalid timestamp") )
Functions ¶
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 (*Decoder) ReadOctetString ¶
ReadOctetString reads a fixed length octet string
func (*Decoder) ReadTimestampFixed ¶
ReadTimestampFixed reads a Interledger OER compatible timestamp and converts it into a Golang timestamp
func (*Decoder) ReadUInt16 ¶
ReadUInt16 reads an unsigned 16 bit integer
func (*Decoder) ReadUInt32 ¶
ReadUInt32 reads an unsigned 32 bit integer
func (*Decoder) ReadUInt64 ¶
ReadUInt64 reads an unsigned 64 bit integer
func (*Decoder) ReadVarOctetString ¶
ReadVarOctetString reads an octet string which has a length prefix attached
func (*Decoder) ReadVarString ¶
ReadVarString reads an UTF-8 encoded string
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 (*Encoder) WriteOctetString ¶
WriteOctetString writes a fixed length octet string
func (*Encoder) WriteTimestampFixed ¶
WriteTimestampFixed writes a GeneralizedTime formatted timestamp
func (*Encoder) WriteUInt16 ¶
WriteUInt16 writes an unsigned 16 bit integer
func (*Encoder) WriteUInt32 ¶
WriteUInt32 writes an unsigned 32 bit integer
func (*Encoder) WriteUInt64 ¶
WriteUInt64 writes an unsigned 64 bit integer
func (*Encoder) WriteUInt8 ¶
WriteUInt8 writes an unsigned 8 bit integer
func (*Encoder) WriteVarOctetString ¶
WriteVarOctetString writes an octet string with a length prefix
func (*Encoder) WriteVarString ¶
WriteVarString writes an UTF-8 encoded string