Skip to content

CoderProtocol

ratranqu edited this page Apr 7, 2021 · 2 revisions

CoderProtocol

The protocol Coder describes the primitives required to serialize structures. A Coder accumulates bytes into a buffer which can then be pushed to storage. The reference implementation uses Amino.

public protocol CoderProtocol

Requirements

encode(_:​int64:​)

static func encode(_ to: inout Data, int64: Int64)

encode(_:​int8:​)

static func encode(_ to: inout Data, int8: Int8)

encode(_:​bytes:​)

static func encode<Bytes: DataProtocol>(_ to: inout Data, bytes: Bytes)

decode(_:​from:​)

static func decode<T: Decodable>(_ type: T.Type, from: Data) throws -> T

encode(_:​)

static func encode<T: Encodable>(_ object: T) throws -> Data