cborgen

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotCBORStructPtr      = errors.New("not a cbor.StructPtr")
	ErrNotCBORStructSlicePtr = errors.New("not a cbor.StructSlicePtr")
	ErrTypeNotMatch          = errors.New("model type does not match")
	ErrNotCBORArrayBytes     = errors.New("bytes does not represent a CBOR array")
)

Functions

This section is empty.

Types

type Marsha added in v0.0.2

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

Marsha is a fast Marsha implementation for CBOR backed by `go-ipld-cbor` package and marshaling/unmarshaling code generated by github.com/daotl/cbor-gen package.

func New

func New() *Marsha

New creates a Marsha.

func (*Marsha) MarshalPrimitive added in v0.0.2

func (m *Marsha) MarshalPrimitive(p interface{}) ([]byte, error)

func (*Marsha) MarshalStruct added in v0.0.2

func (m *Marsha) MarshalStruct(p marsha.StructPtr) ([]byte, error)

func (*Marsha) MarshalStructSlice added in v0.0.2

func (m *Marsha) MarshalStructSlice(p marsha.StructSlicePtr) (bin []byte, err error)

func (*Marsha) NewDecoder added in v0.0.2

func (m *Marsha) NewDecoder(r io.Reader) marsha.Decoder

func (*Marsha) NewEncoder added in v0.0.2

func (m *Marsha) NewEncoder(w io.Writer) marsha.Encoder

func (*Marsha) Register added in v0.0.2

func (m *Marsha) Register(i interface{})

Register a Struct type by passing empty a Struct.

func (*Marsha) UnmarshalPrimitive added in v0.0.2

func (m *Marsha) UnmarshalPrimitive(bin []byte, p interface{}) (int, error)

This implementation does not support returning the count of bytes read.

func (*Marsha) UnmarshalStruct added in v0.0.2

func (m *Marsha) UnmarshalStruct(bin []byte, p marsha.StructPtr) (int, error)

func (*Marsha) UnmarshalStructSlice added in v0.0.2

func (m *Marsha) UnmarshalStructSlice(bin []byte, p marsha.StructSlicePtr) (int, error)

type StructPtr

type StructPtr interface {
	marsha.StructPtr

	// MarshalCBOR should be generated by `github.com/daotl/cbor-gen` package.
	// This implements `github.com/daotl/cbor-gen.CBORMarshaler`
	MarshalCBOR(w io.Writer) (int, error)

	// UnmarshalCBOR should be generated by `github.com/daotl/cbor-gen` package.
	// This implements `github.com/daotl/cbor-gen.CBORUnmarshaler`
	UnmarshalCBOR(r io.Reader) (int, error)
}

StructPtr implements `github.com/ipfs-ipld-cbor/encoding.cborMarshaler`

type StructSlicePtr

type StructSlicePtr interface {
	marsha.StructSlicePtr

	// NewStruct should return an empty marsha.Struct.
	NewStructPtr() marsha.StructPtr

	// Append should append `p.Val()` to the `StructSlice` this `StructSlicePtr` points to.
	Append(p StructPtr)
}

Jump to

Keyboard shortcuts

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