/** * IPLD encoder part of the codec. */ export interface BlockEncoder { name: string code: Code encode(data: T): ByteView } /** * IPLD decoder part of the codec. */ export interface BlockDecoder { code: Code decode(bytes: ByteView): T } /** * An IPLD codec is a combination of both encoder and decoder. */ export interface BlockCodec extends BlockEncoder, BlockDecoder {} // This just a hack to retain type information about the data that // is encoded `T` Because it's a union `data` field is never going // to be usable anyway. export type ByteView = | Uint8Array | Uint8Array & { data: T }