Number

public struct Number
  • Encode platform Int to RSTaggedData with a tag of WellKnownTags.int or .long depending on the platform

    Declaration

    Swift

    public static func encode(_ value: Int) -> RSTaggedData?

    Parameters

    value

    the Int value to encode

    Return Value

    An RSTaggedData object with the encoded data or nil if an error is encountered in the encoding process

  • Decode an RSTaggedData tagged with WellKnownTags.int or .long to a platform Int

    Declaration

    Swift

    public static func decode(_ value: RSTaggedData) -> Int?

    Parameters

    value

    RSTaggedData contianing data tagged with WellKnownTags.int or a .long

    Return Value

    A platform native Int or nil if an error is encountered in the decoding process

  • Encode an Int32 to RSTaggedData with a tag of WellKnownTags.int

    Declaration

    Swift

    public static func encode(_ value: Int32) -> RSTaggedData?

    Parameters

    value

    the Int32 value to encode

    Return Value

    An RSTaggedData object with the encoded data or nil if an error is encountered in the encoding process

  • Decode an RSTaggedData tagged with WellKnownTags.int to an Int32

    Declaration

    Swift

    public static func decode(_ data: RSTaggedData) -> Int32?

    Parameters

    value

    RSTaggedData contianing data tagged with WellKnownTags.int

    Return Value

    The decoded Int32 or nil if an error is encountered in the decoding process

  • Encode an Int64 to RSTaggedData with a tag of WellKnownTags.long

    Declaration

    Swift

    public static func encode(_ value: Int64) -> RSTaggedData?

    Parameters

    value

    the Int64 value to encode

    Return Value

    An RSTaggedData object with the encoded data or nil if an error is encountered in the encoding process

  • Decode an RSTaggedData tagged with WellKnownTags.int or .long to an Int64

    Declaration

    Swift

    public static func decode(_ data: RSTaggedData) -> Int64?

    Parameters

    value

    RSTaggedData contianing data tagged with WellKnownTags.int or .long

    Return Value

    The decoded Int32 or nil if an error is encountered in the decoding process

  • Encode a Float to RSTaggedData with a tag of WellKnownTags.float

    Declaration

    Swift

    public static func encode(_ value: Float) -> RSTaggedData?

    Parameters

    value

    the Float value to encode

    Return Value

    An RSTaggedData object with the encoded data or nil if an error is encountered in the encoding process

  • Decode an RSTaggedData tagged with WellKnownTags.float to a Float

    Declaration

    Swift

    public static func decode(_ data: RSTaggedData) -> Float?

    Parameters

    value

    RSTaggedData contianing data tagged with WellKnownTags.float

    Return Value

    The decoded Float or nil if an error is encountered in the decoding process

  • Encode a Float to RSTaggedData with a tag of WellKnownTags.double

    Declaration

    Swift

    public static func encode(_ value: Double) -> RSTaggedData?

    Parameters

    value

    the Double value to encode

    Return Value

    An RSTaggedData object with the encoded data or nil if an error is encountered in the encoding process

  • Decode an RSTaggedData tagged with WellKnownTags.double to a Double

    Declaration

    Swift

    public static func decode(_ data: RSTaggedData) -> Double?

    Parameters

    value

    RSTaggedData contianing data tagged with WellKnownTags.double

    Return Value

    The decoded Double or nil if an error is encountered in the decoding process

  • Encode a numeric value that conforms to ExpressibleByIntegerLiteral to an RSTaggedData with the provided tag

    Declaration

    Swift

    public static func encode<T: ExpressibleByIntegerLiteral>(
        type: T.Type,
        _ value: T,
        tag: WellKnownTags
    ) -> RSTaggedData

    Parameters

    type

    The type of data to encode

    value

    The numeric value to encode

    tag

    The WellKnownTags tag to include with the data

    Return Value

    An RSTaggedData containing numeric data along with a tag describing the data type

  • Decode a RSTaggedData into a numeric value that conforms to ExpressibleByIntegerLiteral

    Declaration

    Swift

    public static func decode<T: ExpressibleByIntegerLiteral>(
        type: T.Type,
        _ data: RSTaggedData
    ) -> T?

    Parameters

    type

    Type of data to decode

    data

    RSTaggedData to decode

    Return Value

    The decoded ExpressibleByIntegerLiteral if an error is encountered in the decoding process