Documentation - v0.27.0
    Preparing search index...

    Interface IPacketCodec

    Interface declaring handling of received packets. When receiving a packet, its content is sent to feed(), and codec is supposed to emit packet or error event when packet is parsed.

    interface IPacketCodec {
        decode: (
            buf: Bytes,
            eof: boolean,
        ) => MaybePromise<Uint8Array<ArrayBufferLike> | null>;
        encode: (frame: Uint8Array, into: ISyncWritable) => MaybePromise<void>;
        reset: () => void;
        setup?(crypto: ICryptoProvider, log: Logger): void;
        tag(): MaybePromise<Uint8Array<ArrayBufferLike>>;
    }

    Hierarchy

    • IFrameDecoder
    • IFrameEncoder
      • IPacketCodec

    Implemented by

    Index

    Properties

    Methods

    Properties

    decode: (
        buf: Bytes,
        eof: boolean,
    ) => MaybePromise<Uint8Array<ArrayBufferLike> | null>

    Decode a frame from a buffer

    Important implementation notice: When returning byte arrays, make sure that the returned array is not a view into the original buffer, as the underlying buffer may get invalidated

    encode: (frame: Uint8Array, into: ISyncWritable) => MaybePromise<void>

    Encode a frame into a writable stream

    reset: () => void

    Reset the encoder, should it have any internal state

    Methods