@tgsnake/skema
    Preparing search index...

    Class Bool

    Represents a boolean value in a custom serialization format.

    The Bool class provides static methods to serialize and deserialize boolean values to and from a specific binary format, using the BoolTrue and BoolFalse representations. It extends the TLObject base class and overrides its serialization methods.

    • The write method serializes a boolean value into a Buffer using the appropriate representation for true or false.
    • The read method asynchronously reads a boolean value from a BytesIO stream, interpreting the value based on a 32-bit unsigned integer comparison.
    const buffer = Bool.write(true); // Serializes `true` to Buffer
    const value = await Bool.read(bytesIO); // Deserializes from BytesIO to boolean

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _slots: string[]

    Internal array of slot names for the object.

    className: string = 'Bool'

    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.

    • Asynchronously reads a boolean value from the provided BytesIO stream.

      This method reads a 32-bit unsigned integer (little-endian) from the stream and compares it to BoolTrue.ID to determine the boolean value.

      Parameters

      • data: BytesIO

        The BytesIO instance to read from.

      • ..._arg: any[]

        Additional arguments (unused).

      Returns Promise<boolean>

      A promise that resolves to true if the read value equals BoolTrue.ID, otherwise false.

    • Serializes a boolean value into a Buffer.

      Parameters

      • value: boolean

        The boolean value to serialize.

      Returns Buffer

      A Buffer representing the serialized boolean value. If value is true, returns the result of BoolTrue.write(); otherwise, returns the result of BoolFalse.write().