@tgsnake/skema
    Preparing search index...

    Class Bytes

    Serializer and deserializer for raw, variable-length byte arrays.

    In MTProto, raw byte arrays are serialized with a custom length-prefix scheme:

    • If the array is 253 bytes or shorter:
      • The first byte contains the exact length.
      • Followed by the raw payload bytes.
      • Followed by 0-3 padding bytes to align the entire block to a 4-byte boundary.
    • If the array is longer than 253 bytes:
      • The first byte is written as exactly 254 (0xfe).
      • The next 3 bytes contain the little-endian length.
      • Followed by the raw payload bytes.
      • Followed by 0-3 padding bytes to align the entire block to a 4-byte boundary.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _slots: string[]

    The internal slot list storing serialization field property names.

    className: string

    The canonical string name of this class representation.

    classType: string

    The underlying classification type (e.g. request, constructor, function).

    cls: any = ...

    A dynamic reference to the current subclass constructor. Enables late static binding for instance methods to access static helper operations.

    constructorId: number

    The unique 32-bit integer identifier (CRC32 checksum) of this TL constructor.

    subclassOfId: number

    The unique 32-bit integer identifier of the parent/abstract type this TL subclass represents.

    Methods

    • Deserializes a binary stream into this specific TLObject instance.

      Parameters

      • data: BytesIO

        The BytesIO buffer stream containing the serialized TLObject.

      • ...args: any[]

        Additional arguments passed down to the read parser.

      Returns Promise<any>

      A promise resolving to the parsed instance.

    • Serializes the TLObject instance to a clean JSON-compatible representation.

      Returns { [key: string]: any }

      A plain object containing class attributes and values.

      Correctly stringifies extremely large fields (e.g. bigints) that are normally not serializable in standard JSON.stringify calls.

    • Formats the TLObject into a structured string.

      Returns string

      A string starting with the constructor name followed by a pretty JSON payload.

    • Serializes the current class instance into a raw binary buffer.

      Parameters

      • ...args: any[]

        Arguments passed down to the writer.

      Returns Buffer

      A Buffer containing the serialized representation of this object.

    • Reads, decodes, and aligns a variable-length byte array from a binary stream.

      Parameters

      • data: BytesIO

        The BytesIO stream to read the byte array from.

      • ..._args: any[]

        Unused additional parameters.

      Returns Promise<Buffer<ArrayBufferLike>>

      A promise resolving to the decoded Node.js Buffer.

    • Serializes a Node.js Buffer value into a length-prefixed and padded MTProto binary structure.

      Parameters

      • value: Buffer

        The input Buffer to serialize.

      Returns Buffer

      A Buffer containing the formatted prefix, data, and padding bytes.