Documentation ¶
Overview ¶
Package elements holds the logic to encode and decode the BSON element types from native Go to BSON binary and vice versa.
These are low level helper methods, so they do not encode or decode BSON elements, only the specific types, e.g. these methods do not encode, decode, or identify a BSON element, so they won't read the identifier byte and they won't parse out the key string. There are encoder and decoder helper methods for the CString BSON element type, so this package can be used to parse keys.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Double DoubleNS String StringNS Document DocumentNS Array ArrayNS Binary BinNS ObjectID ObjectIDNS Boolean BooleanNS DateTime DatetimeNS Regex RegexNS DBPointer DBPointerNS JavaScript JavaScriptNS Symbol SymbolNS CodeWithScope CodeWithScopeNS Int32 Int32NS Timestamp TimestampNS Int64 Int64NS Decimal128 Decimal128NS CString CStringNS Byte BSONByteNS )
These variables are used as namespaces for methods pertaining to encoding individual BSON types.
var ErrTooSmall = errors.New("element: The provided slice is too small")
ErrTooSmall indicates that slice provided to encode into is not large enough to fit the data.
Functions ¶
This section is empty.
Types ¶
type ArrayNS ¶
type ArrayNS struct{}
ArrayNS is a namespace for encoding BSON Array elements.
type BinNS ¶
type BinNS struct{}
BinNS is a namespace for encoding BSON Binary elements.
type BooleanNS ¶
type BooleanNS struct{}
BooleanNS is a namespace for encoding BSON Boolean elements.
type CStringNS ¶
type CStringNS struct{}
CStringNS is a namespace for encoding BSON CString elements.
type CodeWithScopeNS ¶
type CodeWithScopeNS struct{}
CodeWithScopeNS is a namespace for encoding BSON CodeWithScope elements.
type DBPointerNS ¶
type DBPointerNS struct{}
DBPointerNS is a namespace for encoding BSON DBPointer elements.
type DatetimeNS ¶
type DatetimeNS struct{}
DatetimeNS is a namespace for encoding BSON Datetime elements.
type Decimal128NS ¶
type Decimal128NS struct{}
Decimal128NS is a namespace for encoding BSON Decimal128 elements.
func (Decimal128NS) Element ¶
func (Decimal128NS) Element(start uint, writer []byte, key string, d decimal.Decimal128) (int, error)
Element encodes a decimal128 and a key into a BSON decimal128 element and serializes the bytes to the provided writer.
func (Decimal128NS) Encode ¶
func (Decimal128NS) Encode(start uint, writer []byte, d decimal.Decimal128) (int, error)
Encode encodes a decimal128 into a BSON decimal128 element and serializes the bytes to the provided writer.
type DocumentNS ¶
type DocumentNS struct{}
DocumentNS is a namespace for encoding BSON Document elements.
type DoubleNS ¶
type DoubleNS struct{}
DoubleNS is a namespace for encoding BSON Double elements.
type Int32NS ¶
type Int32NS struct{}
Int32NS is a namespace for encoding BSON Int32 elements.
type Int64NS ¶
type Int64NS struct{}
Int64NS is a namespace for encoding BSON Int64 elements.
type JavaScriptNS ¶
type JavaScriptNS struct{}
JavaScriptNS is a namespace for encoding BSON JavaScript elements.
type ObjectIDNS ¶
type ObjectIDNS struct{}
ObjectIDNS is a namespace for encoding BSON ObjectID elements.
type RegexNS ¶
type RegexNS struct{}
RegexNS is a namespace for encoding BSON Regex elements.
type StringNS ¶
type StringNS struct{}
StringNS is a namespace for encoding BSON String elements.
type SymbolNS ¶
type SymbolNS struct{}
SymbolNS is a namespace for encoding BSON Symbol elements.
type TimestampNS ¶
type TimestampNS struct{}
TimestampNS is a namespace for encoding Timestamp Double elements.