ubjson

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

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

Go to latest
Published: Oct 2, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v interface{}, options ...MarshalOption) ([]byte, error)

func Unmarshal

func Unmarshal(data []byte, v interface{}, options ...UnmarshalOption) error

Types

type InvalidUnmarshalError

type InvalidUnmarshalError struct {
	Type reflect.Type
}

An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)

func (*InvalidUnmarshalError) Error

func (e *InvalidUnmarshalError) Error() string

type MarshalOption

type MarshalOption interface {
	// contains filtered or unexported methods
}

type Marshaler

type Marshaler interface {
	MarshalUBJSON() ([]byte, error)
}

Marshaler is the interface implemented by types that can marshal themselves into valid UBJSON.

type MarshalerError

type MarshalerError struct {
	Type reflect.Type
	Err  error
}

A MarshalerError represents an error from calling a MarshalUBJSON or MarshalText method.

func (*MarshalerError) Error

func (e *MarshalerError) Error() string

func (*MarshalerError) Unwrap

func (e *MarshalerError) Unwrap() error

type Number

type Number string

TODO: Remove! A Number represents a UBJSON number literal.

type Option

type Option interface {
	UnmarshalOption
	MarshalOption
}

func WithTagName

func WithTagName(s string) Option

type SyntaxError

type SyntaxError struct {
	Offset int64 // error occurred after reading Offset bytes
	// contains filtered or unexported fields
}

A SyntaxError is a description of a UBJSON syntax error.

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

type UnmarshalOption

type UnmarshalOption interface {
	// contains filtered or unexported methods
}

type UnmarshalTypeError

type UnmarshalTypeError struct {
	Value  string       // description of UBJSON value - "bool", "array", "number -5"
	Type   reflect.Type // type of Go value it could not be assigned to
	Offset int64        // error occurred after reading Offset bytes
	Struct string       // name of the struct type containing the field
	Field  string       // the full path from root node to the field
}

An UnmarshalTypeError describes a UBJSON value that was not appropriate for a value of a specific Go type.

func (*UnmarshalTypeError) Error

func (e *UnmarshalTypeError) Error() string

type Unmarshaler

type Unmarshaler interface {
	UnmarshalUBJSON([]byte) error
}

Unmarshaler is the interface implemented by types that can unmarshal a UBJSON description of themselves. The input can be assumed to be a valid encoding of a UBJSON value. UnmarshalUBJSON must copy the UBJSON data if it wishes to retain the data after returning.

By convention, to approximate the behavior of Unmarshal itself, Unmarshalers implement UnmarshalUBJSON([]byte("null")) as a no-op.

type UnsupportedTypeError

type UnsupportedTypeError struct {
	Type reflect.Type
}

An UnsupportedTypeError is returned by Marshal when attempting to encode an unsupported value type.

func (*UnsupportedTypeError) Error

func (e *UnsupportedTypeError) Error() string

type UnsupportedValueError

type UnsupportedValueError struct {
	Value reflect.Value
	Str   string
}

func (*UnsupportedValueError) Error

func (e *UnsupportedValueError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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