package elements
import "go.mongodb.org/mongo-driver/bson/elements"
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 ¶
- Variables
- type ArrayNS
- func (ArrayNS) Element(start uint, writer []byte, key string, arr []byte) (int, error)
- func (ArrayNS) Encode(start uint, writer []byte, arr []byte) (int, error)
- type BSONByteNS
- type BinNS
- func (BinNS) Element(start uint, writer []byte, key string, b []byte, btype byte) (int, error)
- func (BinNS) Encode(start uint, writer []byte, b []byte, btype byte) (int, error)
- type BooleanNS
- func (BooleanNS) Element(start uint, writer []byte, key string, b bool) (int, error)
- func (BooleanNS) Encode(start uint, writer []byte, b bool) (int, error)
- type CStringNS
- type CodeWithScopeNS
- func (CodeWithScopeNS) Element(start uint, writer []byte, key string, code string, scope []byte) (int, error)
- func (CodeWithScopeNS) Encode(start uint, writer []byte, code string, doc []byte) (int, error)
- type DBPointerNS
- func (DBPointerNS) Element(start uint, writer []byte, key string, ns string, oid [12]byte) (int, error)
- func (DBPointerNS) Encode(start uint, writer []byte, ns string, oid [12]byte) (int, error)
- type DatetimeNS
- func (DatetimeNS) Element(start uint, writer []byte, key string, dt int64) (int, error)
- func (DatetimeNS) Encode(start uint, writer []byte, dt int64) (int, error)
- type Decimal128NS
- func (Decimal128NS) Element(start uint, writer []byte, key string, d decimal.Decimal128) (int, error)
- func (Decimal128NS) Encode(start uint, writer []byte, d decimal.Decimal128) (int, error)
- type DocumentNS
- func (DocumentNS) Element(start uint, writer []byte, key string, doc []byte) (int, error)
- func (DocumentNS) Encode(start uint, writer []byte, doc []byte) (int, error)
- type DoubleNS
- func (DoubleNS) Element(start uint, writer []byte, key string, f float64) (int, error)
- func (DoubleNS) Encode(start uint, writer []byte, f float64) (int, error)
- type Int32NS
- func (Int32NS) Element(start uint, writer []byte, key string, i int32) (int, error)
- func (Int32NS) Encode(start uint, writer []byte, i int32) (int, error)
- type Int64NS
- func (Int64NS) Element(start uint, writer []byte, key string, i int64) (int, error)
- func (Int64NS) Encode(start uint, writer []byte, i int64) (int, error)
- type JavaScriptNS
- func (JavaScriptNS) Element(start uint, writer []byte, key string, code string) (int, error)
- func (JavaScriptNS) Encode(start uint, writer []byte, code string) (int, error)
- type ObjectIDNS
- func (ObjectIDNS) Element(start uint, writer []byte, key string, oid [12]byte) (int, error)
- func (ObjectIDNS) Encode(start uint, writer []byte, oid [12]byte) (int, error)
- type RegexNS
- func (RegexNS) Element(start uint, writer []byte, key string, pattern, options string) (int, error)
- func (RegexNS) Encode(start uint, writer []byte, pattern, options string) (int, error)
- type StringNS
- func (StringNS) Element(start uint, writer []byte, key string, s string) (int, error)
- func (StringNS) Encode(start uint, writer []byte, s string) (int, error)
- type SymbolNS
- func (SymbolNS) Element(start uint, writer []byte, key string, symbol string) (int, error)
- func (SymbolNS) Encode(start uint, writer []byte, symbol string) (int, error)
- type TimestampNS
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.
ErrTooSmall indicates that slice provided to encode into is not large enough to fit the data.
Types ¶
type ArrayNS ¶
type ArrayNS struct{}
ArrayNS is a namespace for encoding BSON Array elements.
func (ArrayNS) Element ¶
Element encodes an array and a key into a BSON array element and serializes the bytes to the provided writer.
func (ArrayNS) Encode ¶
Encode encodes an array into a BSON array element and serializes the bytes to the provided writer.
type BSONByteNS ¶
type BSONByteNS struct{}
BSONByteNS is a namespace for encoding a single byte.
func (BSONByteNS) Encode ¶
Encode encodes a C-style string into a BSON CString element and serializes the bytes to the provided writer.
type BinNS ¶
type BinNS struct{}
BinNS is a namespace for encoding BSON Binary elements.
func (BinNS) Element ¶
Element encodes a []byte and a key into a BSON binary element and serializes the bytes to the provided writer.
func (BinNS) Encode ¶
Encode encodes a []byte into a BSON binary element and serializes the bytes to the provided writer.
type BooleanNS ¶
type BooleanNS struct{}
BooleanNS is a namespace for encoding BSON Boolean elements.
func (BooleanNS) Element ¶
Element encodes a boolean and a key into a BSON boolean element and serializes the bytes to the provided writer.
func (BooleanNS) Encode ¶
Encode encodes a boolean into a BSON boolean element and serializes the bytes to the provided writer.
type CStringNS ¶
type CStringNS struct{}
CStringNS is a namespace for encoding BSON CString elements.
func (CStringNS) Encode ¶
Encode encodes a C-style string into a BSON CString element and serializes the bytes to the provided writer.
type CodeWithScopeNS ¶
type CodeWithScopeNS struct{}
CodeWithScopeNS is a namespace for encoding BSON CodeWithScope elements.
func (CodeWithScopeNS) Element ¶
func (CodeWithScopeNS) Element(start uint, writer []byte, key string, code string, scope []byte) (int, error)
Element encodes a code and scope doc and a key into a BSON CodeWithScope element and serializes the bytes to the provided writer.
func (CodeWithScopeNS) Encode ¶
Encode encodes a code and scope doc into a BSON CodeWithScope element and serializes the bytes to the provided writer.
type DBPointerNS ¶
type DBPointerNS struct{}
DBPointerNS is a namespace for encoding BSON DBPointer elements.
func (DBPointerNS) Element ¶
func (DBPointerNS) Element(start uint, writer []byte, key string, ns string, oid [12]byte) (int, error)
Element encodes a DBPointer and a key into a BSON DBPointer element and serializes the bytes to the provided writer.
func (DBPointerNS) Encode ¶
Encode encodes a DBPointer into a BSON DBPointer element and serializes the bytes to the provided writer.
type DatetimeNS ¶
type DatetimeNS struct{}
DatetimeNS is a namespace for encoding BSON Datetime elements.
func (DatetimeNS) Element ¶
Element encodes a Datetime and a key into a BSON Datetime element and serializes the bytes to the provided writer.
func (DatetimeNS) Encode ¶
Encode encodes a Datetime into a BSON Datetime element and serializes the bytes to the provided writer.
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.
func (DocumentNS) Element ¶
Element encodes a Document and a key into a BSON document element and serializes the bytes to the provided writer.
func (DocumentNS) Encode ¶
Encode encodes a Document into a BSON document element and serializes the bytes to the provided writer.
type DoubleNS ¶
type DoubleNS struct{}
DoubleNS is a namespace for encoding BSON Double elements.
func (DoubleNS) Element ¶
Element encodes a float64 and a key into a BSON double element and serializes the bytes to the provided writer.
func (DoubleNS) Encode ¶
Encode encodes a float64 into a BSON double element and serializes the bytes to the provided writer.
type Int32NS ¶
type Int32NS struct{}
Int32NS is a namespace for encoding BSON Int32 elements.
func (Int32NS) Element ¶
Element encodes an int32 and a key into a BSON int32 element and serializes the bytes to the provided writer.
func (Int32NS) Encode ¶
Encode encodes an int32 into a BSON int32 element and serializes the bytes to the provided writer.
type Int64NS ¶
type Int64NS struct{}
Int64NS is a namespace for encoding BSON Int64 elements.
func (Int64NS) Element ¶
Element encodes a int64 and a key into a BSON int64 element and serializes the bytes to the provided writer.
func (Int64NS) Encode ¶
Encode encodes a int64 into a BSON int64 element and serializes the bytes to the provided writer.
type JavaScriptNS ¶
type JavaScriptNS struct{}
JavaScriptNS is a namespace for encoding BSON JavaScript elements.
func (JavaScriptNS) Element ¶
Element encodes a JavaScript string and a key into a BSON JavaScript element and serializes the bytes to the provided writer.
func (JavaScriptNS) Encode ¶
Encode encodes a JavaScript string into a BSON JavaScript element and serializes the bytes to the provided writer.
type ObjectIDNS ¶
type ObjectIDNS struct{}
ObjectIDNS is a namespace for encoding BSON ObjectID elements.
func (ObjectIDNS) Element ¶
Element encodes a ObjectID and a key into a BSON ObjectID element and serializes the bytes to the provided writer.
func (ObjectIDNS) Encode ¶
Encode encodes an ObjectID into a BSON ObjectID element and serializes the bytes to the provided writer.
type RegexNS ¶
type RegexNS struct{}
RegexNS is a namespace for encoding BSON Regex elements.
func (RegexNS) Element ¶
Element encodes a regex and a key into a BSON regex element and serializes the bytes to the provided writer.
func (RegexNS) Encode ¶
Encode encodes a regex into a BSON regex element and serializes the bytes to the provided writer.
type StringNS ¶
type StringNS struct{}
StringNS is a namespace for encoding BSON String elements.
func (StringNS) Element ¶
Element encodes a string and a key into a BSON string element and serializes the bytes to the provided writer.
func (StringNS) Encode ¶
Encode encodes a string into a BSON string element and serializes the bytes to the provided writer.
type SymbolNS ¶
type SymbolNS struct{}
SymbolNS is a namespace for encoding BSON Symbol elements.
func (SymbolNS) Element ¶
Element encodes a symbol and a key into a BSON symbol element and serializes the bytes to the provided writer.
func (SymbolNS) Encode ¶
Encode encodes a symbol into a BSON symbol element and serializes the bytes to the provided writer.
type TimestampNS ¶
type TimestampNS struct{}
TimestampNS is a namespace for encoding Timestamp Double elements.
func (TimestampNS) Element ¶
Element encodes a timestamp and a key into a BSON timestamp element and serializes the bytes to the provided writer.
func (TimestampNS) Encode ¶
Encode encodes a timestamp into a BSON timestamp element and serializes the bytes to the provided writer.
Source Files ¶
elements.go
- Version
- v0.0.15
- Published
- Sep 27, 2018
- Platform
- js/wasm
- Imports
- 5 packages
- Last checked
- 2 hours ago –
Tools for package owners.