Type alias Codec<T>

Codec<T>: {
    decode: ((input: Buffer) => T);
    encode: ((input: T) => Buffer);
    name: string;
}

A codec defines a bi-directional mapping between a binary representation (in the form of a Buffer) and a logical representation (in some other type). The codec is responsible for encoding instances of the logical type to Buffers, and decoding Buffers to instances of the logical type.

Type Parameters

  • T = string

    The logical type of the codec

Type declaration

  • decode: ((input: Buffer) => T)
      • (input: Buffer): T
      • Decode a binary representation into an instance of the logical type

        Parameters

        • input: Buffer

        Returns T

  • encode: ((input: T) => Buffer)
      • (input: T): Buffer
      • Encode an instance of the logical type into a binary representation

        Parameters

        • input: T

        Returns Buffer

  • name: string

    The name of the codec

Generated using TypeDoc