as(_:)
Attempts to load an instance of UnixMillisecond
from this variant.
func `as`(_: UnixMillisecond.Type) -> UnixMillisecond?
Returns
The payload of this variant if it matches millisecond(_:)
, nil otherwise.
Attempts to load an instance of UnixMillisecond
from this variant.
func `as`(_: UnixMillisecond.Type) -> UnixMillisecond?
s7BSONABI4BSONO8AnyValueO2asy8UnixTime0F11MillisecondVSgAImF
What are these?59UFQ
The payload of this variant if it matches millisecond(_:)
, nil otherwise.
import BSONABI
Models the BSON type system and the binary interface of the BSON serialization format.
@frozen enum AnyValue
Any BSON value.
@frozen enum BSON
The namespace for all BSON types.
@frozen struct UnixMillisecond
A low-precision instant in time, measured in milliseconds since the Unix epoch.
case millisecond(UnixMillisecond)
UTC milliseconds since the Unix epoch.
init(arrayLiteral: `Self`...)
init(booleanLiteral: Bool)
init(dictionaryLiteral: (BSON.Key, `Self`)...)
init(floatLiteral: Double)
init(integerLiteral: Int)
Creates an instance initialized to the specified integer value. It will be an int32(_:)
value if it fits, otherwise it will be an int64(_:)
.
init(stringLiteral: String)
var binary: BSON.BinaryView<ArraySlice<UInt8>>? { get }
Attempts to unwrap a binary array from this variant.
var document: BSON.Document? { get }
Attempts to unwrap a document from this variant.
var list: BSON.List? { get }
Attempts to unwrap a list from this variant.
var size: Int { get }
The size of this variant value when encoded.
var type: BSON.AnyType { get }
The type of this variant value.
var utf8: BSON.UTF8View<ArraySlice<UInt8>>? { get }
Attempts to unwrap an instance of UTF8View
from this variant. Its UTF-8 code units will not be validated, which allowes this method to return in constant time.
func `as`(_: BSON.Decimal128.Type) -> BSON.Decimal128?
Attempts to load an instance of Decimal128
from this variant.
func `as`(_: BSON.Identifier.Type) -> BSON.Identifier?
Attempts to load an instance of Identifier
from this variant.
func `as`(_: BSON.Max.Type) -> BSON.Max?
Attempts to load a max
key from this variant.
func `as`(_: BSON.Min.Type) -> BSON.Min?
Attempts to load a min
key from this variant.
func `as`(_: BSON.Null.Type) -> BSON.Null?
Attempts to load an explicit null
from this variant.
func `as`(_: BSON.Regex.Type) -> BSON.Regex?
Attempts to load an instance of Regex
from this variant.
func `as`(_: String.Type) -> String?
Attempts to load an instance of String
from this variant. Its UTF-8 code units will be validated (and repaired if needed).
func `as`(_: Bool.Type) -> Bool?
Attempts to load an instance of Bool
from this variant.
func `as`<Integer>(_: Integer.Type) throws -> Integer? where Integer : FixedWidthInteger
Attempts to load an instance of some FixedWidthInteger
from this variant.
func `as`<Fraction>(_: Fraction.Type) -> Fraction? where Fraction : BinaryFloatingPoint
Attempts to load an instance of some BinaryFloatingPoint
type from this variant.
func cast<T>(with cast: (`Self`) throws -> T?) throws -> T
Promotes a nil result to a thrown TypecastError
.