BSON
public enum BSON
extension BSON: ExpressibleByStringLiteral
extension BSON: ExpressibleByBooleanLiteral
extension BSON: ExpressibleByFloatLiteral
extension BSON: ExpressibleByIntegerLiteral
extension BSON: ExpressibleByDictionaryLiteral
extension BSON: ExpressibleByArrayLiteral
extension BSON: Equatable
extension BSON: Hashable
extension BSON: Codable
Enum representing a BSON value.
See also
bsonspec.org-
A BSON double.
Declaration
Swift
case double(Double)
-
A BSON string.
Declaration
Swift
case string(String)
-
A BSON document.
Declaration
Swift
case document(Document)
-
A BSON array.
Declaration
Swift
indirect case array([BSON])
-
A BSON binary.
Declaration
Swift
case binary(Binary)
-
A BSON undefined.
Declaration
Swift
case undefined
-
A BSON ObjectId.
Declaration
Swift
case objectId(ObjectId)
-
A BSON boolean.
Declaration
Swift
case bool(Bool)
-
A BSON UTC datetime.
Declaration
Swift
case datetime(Date)
-
A BSON null.
Declaration
Swift
case null
-
A BSON regular expression.
Declaration
Swift
case regex(RegularExpression)
-
A BSON dbPointer.
Declaration
Swift
case dbPointer(DBPointer)
-
A BSON symbol.
Declaration
Swift
case symbol(Symbol)
-
A BSON JavaScript code.
Declaration
Swift
case code(Code)
-
A BSON JavaScript code with scope.
Declaration
Swift
case codeWithScope(CodeWithScope)
-
A BSON int32.
Declaration
Swift
case int32(Int32)
-
A BSON timestamp.
Declaration
Swift
case timestamp(Timestamp)
-
A BSON int64.
Declaration
Swift
case int64(Int64)
-
A BSON Decimal128.
Declaration
Swift
case decimal128(Decimal128)
-
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 a.regex
, return it as aRegularExpression
. Otherwise, return nil.Declaration
Swift
public var regexValue: RegularExpression? { get }
-
If this
BSON
is a.codeWithScope
, return it as aCodeWithScope
. Otherwise, return nil.Declaration
Swift
public var codeWithScopeValue: CodeWithScope? { 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 a.date
, return it as aDate
. Otherwise, return nil.Declaration
Swift
public var dateValue: Date? { get }
-
If this
BSON
is an.array
, return it as an[BSON]
. Otherwise, return nil.Declaration
Swift
public var arrayValue: [BSON]? { 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.bool
, return it as anBool
. Otherwise, return nil.Declaration
Swift
public var boolValue: Bool? { 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.decimal128
, return it as aDecimal128
. Otherwise, return nil.Declaration
Swift
public var decimal128Value: Decimal128? { 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 asInt() -> 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 asInt32() -> 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 asInt64() -> Int64?
-
Return this BSON as a
Double
if possible. This will coerce numeric cases (e.g..decimal128
) into aDouble
if such coercion would be lossless.Declaration
Swift
public func asDouble() -> Double?
-
Return this BSON as a
Decimal128
if possible. This will coerce numeric cases (e.g..double
) into aDecimal128
if such coercion would be lossless.Declaration
Swift
public func asDecimal128() -> Decimal128?
-
Declaration
Swift
public init(stringLiteral value: String)
-
Declaration
Swift
public init(booleanLiteral value: Bool)
-
Declaration
Swift
public init(floatLiteral value: Double)
-
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(dictionaryLiteral elements: (String, BSON)...)
-
Declaration
Swift
public init(arrayLiteral elements: BSON...)
-
Declaration
Swift
public init(from decoder: Decoder) throws
-
Declaration
Swift
public func encode(to encoder: Encoder) throws