Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PbTranscoder

Transcodes objects according to the protocol buffers spec.

Hierarchy

  • PbTranscoder

Index

Constructors

constructor

  • new PbTranscoder(__namedParameters: PbTranscoderOptions): PbTranscoder

Properties

Readonly JSONRoot

JSONRoot: Record<string, any>

Readonly delType

delType: string

Readonly methodEnumName

methodEnumName: string

Private root

root: Root

Readonly syncType

syncType: string

Private type

type: Type

Methods

decode

  • decode(buf: Buffer): ProtocolObject
  • Decodes entire protocol object according to the given service spec.

    Parameters

    • buf: Buffer

      Buffer to decode

    Returns ProtocolObject

    The decoded object

encode

  • encode(obj: Record<string, any>): Buffer
  • Encodes entire protocol object according to the given service spec.

    Parameters

    • obj: Record<string, any>

      Object to encode

    Returns Buffer

    Encoded Buffer.

getState

  • getState(): string
  • Returns the string representation of the transcoder. Used for saving and restoring.

    Returns string

    The state string.

Static decode

  • decode(buf: Buffer, type?: Type): ProtocolObject
  • Decodes the buffer according to the provided type. Uses the general protocol main type by default. Does not decode service-specific information.

    Parameters

    • buf: Buffer

      Buffer to decode

    • type: Type = ...

      Type used to decode. Defaults to main protocol type.

    Returns ProtocolObject

    The decoded object

Static encode

  • encode(obj: Record<string, any>, type?: Type): Buffer
  • Encodes the object according to the provided type. Uses the general protocol main type by default. Does not encode service-specific information.

    Parameters

    • obj: Record<string, any>

      Object to encode

    • type: Type = ...

      Type used to encode. Defaults to main protocol type.

    Returns Buffer

    The encoded Buffer

Generated using TypeDoc