Array
extension Array: XDRCodable where Element: XDRCodable
Extension making Array conform to XDRCodable when elements are XDRCodable.
Arrays in XDR are encoded with a 32-bit count prefix followed by the elements.
-
Encodes the array to XDR format.
Writes the element count as UInt32 followed by each element.
Declaration
Swift
public func xdrEncode(to encoder: XDREncoder) throws -
Decodes a variable-length array from XDR format.
Reads the element count as UInt32 followed by the elements. This is also the byte reader behind
StringandData, whose elements are singleUInt8values; every other element type occupies at least 4 bytes. The count is validated against the remaining bytes at that minimum width before storage is reserved for it.Throws
StellarSDKError.xdrDecodingError if the count exceeds what the remaining bytes can hold, XDRDecoder.Error if decoding an element failsDeclaration
Swift
public init(fromBinary decoder: XDRDecoder) throws -
Decodes a fixed-length array from XDR format.
Reads exactly
countelements with no count prefix, the layout of an XDR fixed-length array. The count is validated against the remaining bytes at the minimum element width (1 byte forUInt8, 4 bytes otherwise) before storage is reserved for it.Throws
StellarSDKError.xdrDecodingError if the count is negative or exceeds what the remaining bytes can hold, XDRDecoder.Error if decoding an element failsDeclaration
Swift
public init(fromBinary decoder: XDRDecoder, count: Int) throwsParameters
decoderDecoder to read from
countNumber of elements to read
View on GitHub
Install in Dash