BSONABI
Models the BSON type system and the binary interface of the BSON serialization format.
import BSONABIModule information
- Declarations
- 359
- Symbols
- 540
External users should avoid importing this module directly. Instead, import BSON.
Type system
enum AnyValueAny BSON value.
enum AnyTypeA BSON metatype. The raw value of this enumeration is the type code of the associated case in BSON’s ABI.
struct TypeErrorA variant code did not encode a valid BSON type.
struct TypecastError<Value>A decoder failed to cast a variant to an expected value type.
Primitive types
struct MinThe MongoDB min-key. This type has a single state, and is isomorphic to
Void. It is mainly used by the decoding and encoding layers as an API landmark.struct MaxThe MongoDB max-key. This type has a single state, and is isomorphic to
Void. It is mainly used by the decoding and encoding layers as an API landmark.struct IdentifierA MongoDB object reference. This type models a MongoDB
ObjectId.struct Decimal128An opaque IEEE 754-2008 decimal.
struct RegexA MongoDB regex.
struct UnixMillisecondA low-precision instant in time, measured in milliseconds since the Unix epoch.
String-like types
struct BinaryBuffer<Element>A
BinaryBufferis a typed view of anArraySliceas a densely-packed buffer of trivialElements. It’s a good idea to use something unpretentious like a tuple of fixed-width integers for theElementtype, to avoid unexpected padding behavior.enum BinaryFrameSpecifies the interpretation of a length header attached to a
binaryarray.struct BinaryShapeAn efficient interface for checking the shape of a binary array at run time.
struct BinarySubtypeA BSON binary metatype. This type’s public API performs canonicalization and therefore instances of this type are safe to compare.
struct BinaryView<Bytes>A BSON binary array.
struct UTF8View<Bytes>A BSON UTF-8 string. This string is allowed to contain null bytes.
Container types
struct Liststruct DocumentThe
Documenttype models the “universal” BSON DSL.
Container fields
struct KeyA BSON field key. This type wraps a
rawValuethat is guaranteed to never contain null bytes. (Null bytes in a BSON field key can be exploited to perform SQL injection.)protocol KeyspaceA keyspace is a type that is used to identify an arbitrary associative mapping within a
BSON.Document. Keyspaces are not the same as schema keys, which are a fixed (but evolving) set of names that are used to identify structural properties in a model type.struct FieldEncoderA type that can serialize any BSON container element.
Binary interface
protocol BufferTraversableA framed type that BSON parsers can traverse in constant time.
protocol BufferFrameA type that augments a
BufferFrameTypeconformance with a BSON metatype value. This is a derived protocol because it is sometimes useful to repurpose the BSON frame parsing machinery for additional (fictional) frame types that never appear in BSON data.
Binary frame types
enum BinaryFrameSpecifies the interpretation of a length header attached to a
binaryarray.enum DocumentFrameSpecifies the interpretation of a length header attached to a
document, or alistdocument.enum UTF8FrameSpecifies the interpretation of a length header attached to UTF-8
string.
Parsing and decoding
This module only implements the basic infrastructure for BSON decoding. Most of the public decoding interface is in BSONDecoding.
protocol Decoderstruct InputA type for managing BSON parsing state. Most users of this library should not need to interact with it directly.
Serialization and encoding
This module only implements the basic infrastructure for BSON encoding. Most of the public encoding interface is in BSONEncoding.
protocol Encoder<Frame>struct OutputA type for serializing raw BSON tokens. This is used to implement BSON DSLs, and most users of this library should not need to interact with it directly.