DataDecodingStrategy
public enum DataDecodingStrategy
Enum representing the various strategies for decoding Data
s from BSON.
As per the BSON specification, the default strategy is to decode Data
s from BSON binary types with the generic
binary subtype.
See also
bsonspec.org-
Decode
Data
s by deferring to their default decoding implementation.Note: The default decoding implementation attempts to decode the
Data
from a[UInt8]
, but because BSON does not support integer types otherInt32
andInt64
, it actually decodes from an[Int32]
stored in BSON. This strategy paired with its corresponding encoding strategy results in an inefficient storage of theData
in BSON.Declaration
Swift
case deferredToData
-
Decode
Data
s stored as theBSONBinary
type (default).Declaration
Swift
case binary
-
Decode
Data
s stored as base64 encoded strings.Declaration
Swift
case base64
-
Decode
Data
s using the provided closure.Declaration
Swift
case custom((_ decoder: Decoder) throws -> Data)