@tgsnake/skema
    Preparing search index...

    Class Bytes

    Bytes is a class representing a sequence of bytes in the Telegram MTProto protocol. It provides methods to read and write these bytes in a specified format.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _slots: string[]

    Internal array of slot names for the object.

    className: string

    Name of the class.

    classType: string

    Type of the class.

    cls: any = ...

    Reference to the constructor of the current class (late static binding).

    constructorId: number

    Unique identifier for the constructor.

    subclassOfId: number

    Identifier for the parent class (if any).

    Methods

    • Reads data from the provided BytesIO instance and processes it using the associated class's read method.

      Parameters

      • data: BytesIO

        The BytesIO instance containing the data to be read.

      • ...args: any[]

        Additional arguments to be passed to the class's read method.

      Returns Promise<any>

      A promise that resolves with the result of the read operation.

    • Serializes the provided arguments using the associated class's write method.

      Parameters

      • ...args: any[]

        The arguments to be serialized.

      Returns Buffer

      The resulting Buffer after serialization.

    • Reads a variable-length buffer from the provided BytesIO stream.

      The method first reads a length prefix from the stream:

      • If the first byte (length) is less than or equal to 253, it reads that many bytes as the buffer.
      • If the first byte is greater than 253, it reads the next 3 bytes to determine the actual length, then reads that many bytes as the buffer.

      After reading the buffer, it reads additional bytes to align the stream position to a 4-byte boundary.

      Parameters

      • data: BytesIO

        The BytesIO stream to read from.

      • ..._args: any[]

        Additional arguments (unused).

      Returns Promise<Buffer<ArrayBufferLike>>

      A Promise that resolves to the read Buffer.

    • Serializes a Buffer value into a custom binary format with length-prefix encoding and padding.

      • If the buffer length is 253 bytes or less, the output format is: [1 byte length][buffer data][padding to 4-byte alignment]
      • If the buffer length is greater than 253 bytes, the output format is: [1 byte (254)][3 bytes length][buffer data][padding to 4-byte alignment]

      The padding ensures the total length (including prefix and data) is a multiple of 4 bytes.

      Parameters

      • value: Buffer

        The Buffer to serialize.

      Returns Buffer

      A Buffer containing the serialized data with length prefix and padding.