bytes
The raw data backing this document. This slice does not include the trailing null byte that typically appears after its inline field list.
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 bytes: ArraySlice<UInt8> { get }
s7BSONABI4BSONO8DocumentV5bytess10ArraySliceVys5UInt8VGvp
What are these?1VAHF
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.
@frozen struct ArraySlice<Element>
A slice of an Array
, ContiguousArray
, or ArraySlice
instance.
@frozen struct UInt8
An 8-bit unsigned 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 header: Int32 { get }
The length that would be encoded in this document’s prefixed header. Equal to size
.
var isEmpty: Bool { get }
Indicates if this document contains no fields.
var output: BSON.Output
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.
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`)