@tgsnake/skema
    Preparing search index...

    Class Vector

    Vector is a class representing a vector (array) of Telegram MTProto objects. It provides methods to read and write these vectors 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).

    ID: number = 0x1cb5c415

    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 vector of elements from the provided BytesIO stream.

      Parameters

      • data: BytesIO

        The BytesIO stream to read from.

      • Optionaltl: any

        (Optional) A type layer object with a read method for reading each element.

      Returns Promise<any[]>

      A promise that resolves to an array containing the read elements.

      • If tl is provided, its read method is used to read each element.
      • If tl is not provided, Vector.readBare is used with a calculated size for each element.
      • The method first reads the count of elements, then calculates the size of each element based on the remaining buffer length.
    • Reads a value from the provided BytesIO stream based on the specified size.

      • If size is 4, reads and returns an integer using Int.read.
      • If size is 8, reads and returns a long integer using Long.read.
      • For other sizes, reads and returns a TLObject using TLObject.read.

      Parameters

      • data: BytesIO

        The BytesIO stream to read from.

      • size: number

        The size of the value to read (in bytes).

      Returns Promise<any>

      A Promise resolving to the value read from the stream.

    • Serializes an array of values into a Buffer using the Vector schema.

      Parameters

      • value: any[]

        The array of values to serialize.

      • Optionaltl: any

        (Optional) A type layer object that provides a custom write method for serializing each element.

      Returns Buffer

      A Buffer containing the serialized representation of the vector.

      • The method writes the Vector ID, the length of the array, and then serializes each element.
      • If a type layer (tl) is provided, its write method is used for each element; otherwise, each element's own write method is called.