Number
public struct Number
-
Encode platform Int to
RSTaggedData
with a tag ofWellKnownTags
.int
or .long
depending on the platformDeclaration
Swift
public static func encode(_ value: Int) -> RSTaggedData?
Parameters
value
the
Int
value to encodeReturn Value
An
RSTaggedData
object with the encoded data ornil
if an error is encountered in the encoding process -
Decode an
RSTaggedData
tagged withWellKnownTags
.int
or .long
to a platformInt
Declaration
Swift
public static func decode(_ value: RSTaggedData) -> Int?
Parameters
value
RSTaggedData
contianing data tagged withWellKnownTags
.int
or a .long
Return Value
A platform native Int or
nil
if an error is encountered in the decoding process -
Encode an
Int32
toRSTaggedData
with a tag ofWellKnownTags
.int
Declaration
Swift
public static func encode(_ value: Int32) -> RSTaggedData?
Parameters
value
the
Int32
value to encodeReturn Value
An
RSTaggedData
object with the encoded data ornil
if an error is encountered in the encoding process -
Decode an
RSTaggedData
tagged withWellKnownTags
.int
to anInt32
Declaration
Swift
public static func decode(_ data: RSTaggedData) -> Int32?
Parameters
value
RSTaggedData
contianing data tagged withWellKnownTags
.int
Return Value
The decoded
Int32
ornil
if an error is encountered in the decoding process -
Encode an
Int64
toRSTaggedData
with a tag ofWellKnownTags
.long
Declaration
Swift
public static func encode(_ value: Int64) -> RSTaggedData?
Parameters
value
the
Int64
value to encodeReturn Value
An
RSTaggedData
object with the encoded data ornil
if an error is encountered in the encoding process -
Decode an
RSTaggedData
tagged withWellKnownTags
.int
or .long
to anInt64
Declaration
Swift
public static func decode(_ data: RSTaggedData) -> Int64?
Parameters
value
RSTaggedData
contianing data tagged withWellKnownTags
.int
or .long
Return Value
The decoded
Int32
ornil
if an error is encountered in the decoding process -
Encode a Float to
RSTaggedData
with a tag ofWellKnownTags
.float
Declaration
Swift
public static func encode(_ value: Float) -> RSTaggedData?
Parameters
value
the
Float
value to encodeReturn Value
An
RSTaggedData
object with the encoded data ornil
if an error is encountered in the encoding process -
Decode an
RSTaggedData
tagged withWellKnownTags
.float
to aFloat
Declaration
Swift
public static func decode(_ data: RSTaggedData) -> Float?
Parameters
value
RSTaggedData
contianing data tagged withWellKnownTags
.float
Return Value
The decoded
Float
ornil
if an error is encountered in the decoding process -
Encode a Float to
RSTaggedData
with a tag ofWellKnownTags
.double
Declaration
Swift
public static func encode(_ value: Double) -> RSTaggedData?
Parameters
value
the
Double
value to encodeReturn Value
An
RSTaggedData
object with the encoded data ornil
if an error is encountered in the encoding process -
Decode an
RSTaggedData
tagged withWellKnownTags
.double
to aDouble
Declaration
Swift
public static func decode(_ data: RSTaggedData) -> Double?
Parameters
value
RSTaggedData
contianing data tagged withWellKnownTags
.double
Return Value
The decoded
Double
ornil
if an error is encountered in the decoding process -
Encode a numeric value that conforms to
ExpressibleByIntegerLiteral
to anRSTaggedData
with the provided tagDeclaration
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 dataReturn Value
An
RSTaggedData
containing numeric data along with a tag describing the data type -
Decode a
RSTaggedData
into a numeric value that conforms toExpressibleByIntegerLiteral
Declaration
Swift
public static func decode<T: ExpressibleByIntegerLiteral>( type: T.Type, _ data: RSTaggedData ) -> T?
Parameters
type
Type of data to decode
data
RSTaggedData
to decodeReturn Value
The decoded
ExpressibleByIntegerLiteral
if an error is encountered in the decoding process