BSONValue
public protocol BSONValue
A protocol all types representing BSONType
s must implement.
-
Given the
DocumentStorage
backing aDocument
, appends thisBSONValue
to the end.Throws
Throws:
RuntimeError.internalError
if theDocumentStorage
would exceed the maximum size by encoding this key-value pair.UserError.logicError
if the value is anArray
and it contains a non-BSONValue
element.
Declaration
Swift
func encode(to storage: DocumentStorage, forKey key: String) throws
Parameters
storage
A
DocumentStorage
to write to.key
A
String
, the key under which to store the value. -
bsonEquals(_:)
Default implementationFunction to test equality with another
BSONValue
. This function tests for exact BSON equality. This means that differing types with equivalent value are not equivalent.e.g. 4.0 (Double) != 4 (Int)
Default Implementation
Default implementation of
bsonEquals
forBSONValue
s that conform toEquatable
.Declaration
Swift
func bsonEquals(_ other: BSONValue?) -> Bool
Return Value
true
ifself
is equal torhs
,false
otherwise. -
Given a
DocumentIterator
known to have a next value of this type, initializes the value.Throws
UserError.logicError
if the current type of theDocumentIterator
does not correspond to the associated type of thisBSONValue
.Declaration
Swift
static func from(iterator iter: DocumentIterator) throws -> Self