BSON
public enum BSON
extension BSON: ExpressibleByIntegerLiteral
extension BSON: ExpressibleByFloatLiteral
extension BSON: ExpressibleByBooleanLiteral
extension BSON: ExpressibleByDictionaryLiteral
extension BSON: ExpressibleByStringLiteral
extension BSON: ExpressibleByArrayLiteral
extension BSON: Equatable
extension BSON: Hashable
extension BSON: Codable
Enum representing a BSON value.
See also
bsonspec.org-
A BSON document.
Declaration
Swift
case document(BSONDocument)
-
A BSON int32.
Declaration
Swift
case int32(Int32)
-
A BSON int64.
Declaration
Swift
case int64(Int64)
-
A BSON Decimal128
Declaration
Swift
case decimal128(BSONDecimal128)
-
A BSON Array
Declaration
Swift
indirect case array([BSON])
-
A BSON Boolean
Declaration
Swift
case bool(Bool)
-
A BSON UTC datetime.
Declaration
Swift
case datetime(Date)
-
A BSON double.
Declaration
Swift
case double(Double)
-
A BSON string.
Declaration
Swift
case string(String)
-
A BSON Symbol
Declaration
Swift
case symbol(BSONSymbol)
-
A BSON Timestamp
Declaration
Swift
case timestamp(BSONTimestamp)
-
A BSON Binary
Declaration
Swift
case binary(BSONBinary)
-
A BSON Regex
Declaration
Swift
case regex(BSONRegularExpression)
-
A BSON ObjectID
Declaration
Swift
case objectID(_: BSONObjectID = BSONObjectID())
-
A BSON DBPointer
Declaration
Swift
case dbPointer(BSONDBPointer)
-
A BSON Code
Declaration
Swift
case code(BSONCode)
-
A BSON Code with Scope
Declaration
Swift
case codeWithScope(BSONCodeWithScope)
-
A BSON Null
Declaration
Swift
case null
-
A BSON Undefined
Declaration
Swift
case undefined
-
A BSON MinKey
Declaration
Swift
case minKey
-
A BSON MaxKey
Declaration
Swift
case maxKey
-
Initialize a
BSON
from an integer. On 64-bit systems, this will result in an.int64
. On 32-bit systems, this will result in an.int32
.Declaration
Swift
public init(_ int: Int)
-
If this
BSON
is an.int32
, return it as anInt32
. Otherwise, return nil.Declaration
Swift
public var int32Value: Int32? { get }
-
If this
BSON
is an.int64
, return it as anInt64
. Otherwise, return nil.Declaration
Swift
public var int64Value: Int64? { get }
-
If this
BSON
is an.decimal128
, return it as anBSONDecimal128
. Otherwise, return nil.Declaration
Swift
public var decimal128Value: BSONDecimal128? { get }
-
If this
BSON
is a.document
, return it as aBSONDocument
. Otherwise, return nil.Declaration
Swift
public var documentValue: BSONDocument? { get }
-
If this
BSON
is a.array
, return it as a[BSON]
. Otherwise, return nil.Declaration
Swift
public var arrayValue: [BSON]? { get }
-
If this
BSON
is a.bool
, return it as aBool
. Otherwise, return nil.Declaration
Swift
public var boolValue: Bool? { get }
-
If this
BSON
is a.date
, return it as aDate
. Otherwise, return nil.Declaration
Swift
public var dateValue: Date? { get }
-
If this
BSON
is a.double
, return it as aDouble
. Otherwise, return nil.Declaration
Swift
public var doubleValue: Double? { get }
-
If this
BSON
is a.string
, return it as aString
. Otherwise, return nil.Declaration
Swift
public var stringValue: String? { get }
-
If this
BSON
is a.symbol
, return it as aBSONSymbol
. Otherwise, return nil.Declaration
Swift
public var symbolValue: BSONSymbol? { get }
-
If this
BSON
is a.timestamp
, return it as aBSONTimestamp
. Otherwise, return nil.Declaration
Swift
public var timestampValue: BSONTimestamp? { get }
-
If this
BSON
is a.binary
, return it as aBSONBinary
. Otherwise, return nil.Declaration
Swift
public var binaryValue: BSONBinary? { get }
-
If this
BSON
is a.regex
, return it as aBSONRegularExpression
. Otherwise, return nil.Declaration
Swift
public var regexValue: BSONRegularExpression? { get }
-
If this
BSON
is a.objectID
, return it as aBSONObjectID
. Otherwise, return nil.Declaration
Swift
public var objectIDValue: BSONObjectID? { get }
-
If this
BSON
is a.dbPointer
, return it as aBSONDBPointer
. Otherwise, return nil.Declaration
Swift
public var dbPointerValue: BSONDBPointer? { get }
-
If this
BSON
is a.codeWithScope
, return it as aBSONCodeWithScope
. Otherwise, return nil.Declaration
Swift
public var codeWithScopeValue: BSONCodeWithScope? { get }
-
Return this BSON as an
Int
if possible. This will coerce non-integer numeric cases (e.g..double
) into anInt
if such coercion would be lossless.Declaration
Swift
public func toInt() -> Int?
-
Return this BSON as an
Int32
if possible. This will coerce numeric cases (e.g..double
) into anInt32
if such coercion would be lossless.Declaration
Swift
public func toInt32() -> Int32?
-
Return this BSON as an
Int64
if possible. This will coerce numeric cases (e.g..double
) into anInt64
if such coercion would be lossless.Declaration
Swift
public func toInt64() -> Int64?
-
Return this BSON as a
Double
if possible. This will coerce numeric cases (e.g..int32
) into aDouble
if such coercion would be lossless.Declaration
Swift
public func toDouble() -> Double?
-
Return this BSON as a
BSONDecimal128
if possible. This will coerce numeric cases (e.g..double
) into aBSONDecimal128
if such coercion would be lossless.Declaration
Swift
public func toDecimal128() -> BSONDecimal128?
-
Initialize a
BSON
from an integer. On 64-bit systems, this will result in an.int64
. On 32-bit systems, this will result in an.int32
.Declaration
Swift
public init(integerLiteral value: Int)
-
Declaration
Swift
public init(floatLiteral value: Double)
-
Declaration
Swift
public init(booleanLiteral value: Bool)
-
Declaration
Swift
public init(dictionaryLiteral elements: (String, BSON)...)
-
Declaration
Swift
public init(stringLiteral value: String)
-
Declaration
Swift
public init(arrayLiteral elements: BSON...)
-
Declaration
Swift
public init(from decoder: Decoder) throws
-
Declaration
Swift
public func encode(to encoder: Encoder) throws