Documentation ¶
Index ¶
- func DecodeArray(buf []byte) document.Array
- func DecodeDocument(buf []byte) document.Document
- func DecodeValue(t document.ValueType, data []byte) (document.Value, error)
- func EncodeArray(a document.Array) ([]byte, error)
- func EncodeDocument(d document.Document) ([]byte, error)
- func EncodeValue(v document.Value) ([]byte, error)
- type Codec
- type EncodedArray
- type EncodedDocument
- type Encoder
- type FieldHeader
- type Format
- type Header
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeArray ¶
DecodeArray takes a byte slice and returns a lazily decoded array. If buf is malformed, an error will be returned when calling one of the array method.
func DecodeDocument ¶
DecodeDocument takes a byte slice and returns a lazily decoded document. If buf is malformed, an error will be returned when calling one of the document method.
func DecodeValue ¶
DecodeValue takes some encoded data and decodes it to the target type t.
func EncodeArray ¶
EncodeArray encodes a into its binary representation.
func EncodeDocument ¶
EncodeDocument takes a document and encodes it using the encoding.Format type.
Types ¶
type Codec ¶
type Codec struct{}
A Codec is a custom implementation of an encoding.Codec.
func (Codec) NewDocument ¶
NewDocument implements the encoding.Codec interface.
type EncodedArray ¶
type EncodedArray []byte
An EncodedArray implements the document.Array interface on top of an encoded representation of an array. It is useful to avoid decoding the entire array when only a few values are needed.
func (EncodedArray) GetByIndex ¶
func (e EncodedArray) GetByIndex(i int) (document.Value, error)
GetByIndex returns a value by index of the array.
func (EncodedArray) Iterate ¶
Iterate goes through all the values of the array and calls the given function by passing each one of them. If the given function returns an error, the iteration stops.
func (EncodedArray) MarshalJSON ¶
func (e EncodedArray) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
type EncodedDocument ¶
type EncodedDocument []byte
An EncodedDocument implements the document.Document interface on top of an encoded representation of a document. It is useful to avoid decoding the entire document when only a few fields are needed.
func (EncodedDocument) GetByField ¶
func (e EncodedDocument) GetByField(field string) (document.Value, error)
GetByField decodes the selected field.
func (EncodedDocument) Iterate ¶
Iterate decodes each fields one by one and passes them to fn until the end of the document or until fn returns an error.
func (EncodedDocument) MarshalJSON ¶
func (e EncodedDocument) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder encodes Genji documents and values in MessagePack.
func NewEncoder ¶
NewEncoder creates an Encoder that writes in the given writer.
type FieldHeader ¶
type FieldHeader struct { // Size of the name of the field NameSize uint64 // Name of the field Name []byte // Type of the field, corresponds to the Type Type uint64 // Size of the data of the field Size uint64 // Offset describing where the field is located, starting // from the end of the format header. Offset uint64 NameString string // used for encoding // contains filtered or unexported fields }
FieldHeader represents the metadata of a field.
type Format ¶
Format is an encoding format used to encode and decode documents. It is composed of a header and a body. The header defines a list of fields, offsets and relevant metadata. The body contains each fields data one concatenated one after another.