parse(_:)
BSON.List.swift:91func parse<T>(_ transform: (_ element: BSON.AnyValue) throws -> T) throws -> [T]
func parse<T>(_ transform: (_ element: BSON.AnyValue) throws -> T) throws -> [T]
import BSONABI
Models the BSON type system and the binary interface of the BSON serialization format.
@frozen struct List
@frozen enum BSON
The namespace for all BSON types.
@frozen enum AnyValue
Any BSON value.
init()
Creates an empty list.
init(arrayLiteral: BSON.AnyValue...)
init(bytes: ArraySlice<UInt8>)
init(elements: some Sequence<BSON.AnyValue>)
Creates a list-document containing the given elements.
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 list. This collection does not include the trailing null byte that appears after its inline elements list.
var header: Int32 { get }
The length that would be encoded in this list’s prefixed header. Equal to size
.
var isEmpty: Bool { get }
Indicates if this list contains no elements.
var output: BSON.Output
var size: Int { get }
The size of this list 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 lists. Does not parse or validate the operands.
func parse() throws -> [BSON.AnyValue]
Splits this list’s inline key-value pairs into an array containing the values only. Parsing a list is slightly faster than parsing a general Document
, because this method ignores the document keys.
func parse(to decode: (_ element: BSON.AnyValue) throws -> ()) throws
Parses this list into key-value pairs in order, yielding each value to the provided closure. Parsing a list is slightly faster than parsing a general Document
, because this method ignores the document keys.
typealias Frame = BSON.DocumentFrame
init(_ bson: `Self`)
init(bson: `Self`)