DataEncodingStrategy

public enum DataEncodingStrategy

Enum representing the various strategies for encoding Datas.

As per the BSON specification, the default strategy is to encode Datas as BSON binary types with the generic binary subtype.

See also

bsonspec.org
  • Encode the Data by deferring to its default encoding implementation.

    Note: The default encoding implementation attempts to encode the Data as a [UInt8], but because BSON does not support integer types besides Int32 or Int64, it actually gets encoded to BSON as an [Int32]. This results in a space inefficient storage of the Data (using 4 bytes of BSON storage per byte of data).

    Declaration

    Swift

    case deferredToData
  • Encode the Data as a BSON binary type (default).

    Declaration

    Swift

    case binary
  • Encode the Data as a base64 encoded string.

    Declaration

    Swift

    case base64
  • Encode the Data by using the given closure. If the closure does not encode a value, an empty document will be encoded in its place.

    Declaration

    Swift

    case custom((Data, Encoder) throws -> Void)