header
The length that would be encoded in this document’s prefixed header. Equal to size
.
var header: Int32 { get }
The length that would be encoded in this document’s prefixed header. Equal to size
.
var header: Int32 { get }
import BSONABI
Models the BSON type system and the binary interface of the BSON serialization format.
@frozen struct Document
The Document
type models the “universal” BSON DSL.
@frozen enum BSON
The namespace for all BSON types.
var size: Int { get }
The size of this document when encoded with its header and trailing null byte. This is the same as the length encoded in the header itself.
@frozen struct Int32
A 32-bit signed integer value type.
init()
Creates an empty document.
init(bytes: ArraySlice<UInt8>)
Stores the argument in bytes
unchanged.
init(dictionaryLiteral: (BSON.Key, BSON.AnyValue)...)
init(fields: some Collection<(key: BSON.Key, value: BSON.AnyValue)>)
Creates a document containing the given fields, making two passes over the list of fields in order to encode the output without reallocations. The order of the fields will be preserved.
init(key: BSON.Key, value: BSON.AnyValue)
Creates a document containing a single key-value pair.
init(list: BSON.List)
Rebinds the backing storage of this list to a BSON.Document
. This will cause the list to be interpreted as a document with keys numbered from 0 in base-10.
init(slicing bytes: ArraySlice<UInt8>)
Stores the argument in bytes
unchanged. Equivalent to init(bytes:)
.
var bytes: ArraySlice<UInt8> { get }
The raw data backing this document. This slice does not include the trailing null byte that typically appears after its inline field list.
var isEmpty: Bool { get }
Indicates if this document contains no fields.
var output: BSON.Output
static func == (a: `Self`, b: `Self`) -> Bool
Performs an exact byte-wise comparison on two documents. Does not parse or validate the operands. Documents with the same fields in different orders will compare unequal!
mutating func append(contentsOf other: `Self`)
func parse<CodingKey, T>(_ transform: (_ key: CodingKey, _ value: BSON.AnyValue) throws -> T) throws -> [T] where CodingKey : RawRepresentable, CodingKey.RawValue == String
Splits this document’s inline key-value pairs into an array.
func parse<CodingKey>(to decode: (CodingKey, BSON.AnyValue) throws -> ()) throws where CodingKey : RawRepresentable, CodingKey.RawValue == String
Parses this document into key-value pairs in order, yielding each key-value pair to the provided closure.
typealias Frame = BSON.DocumentFrame
init(_ bson: `Self`)
init(bson: `Self`)