# This file was generated by stubgen-pyx v0.2.18 from /Users/long2ice/Developer/long2ice/asyncmy/asyncmy/protocol.pyx

class MysqlPacket:
    """
    Representation of a MySQL response packet.
    Provides an interface for reading/parsing the packet results.
    """
    def __init__(self, data: bytes, encoding: str): ...
    def get_all_data(self) -> bytes: ...
    def read(self, size: int) -> bytes:
        """
        Read the first 'size' bytes in packet and advance cursor past them.
        """
    def read_all(self) -> bytes:
        """Read all remaining data in the packet.

        (Subsequent read() will return errors.)
        """
    def advance(self, length: int):
        """
        Advance the cursor in data buffer 'length' bytes.
        """
    def rewind(self, position: int = 0):
        """
        Set the position of the data buffer cursor to 'position'.
        """
    def get_bytes(self, position: int, length: int = 1) -> bytes:
        """
        Get 'length' bytes starting at 'position'.

        Position is start of payload (first four packet header bytes are not
        included) starting at index '0'.

        No error checking is done.  If requesting outside end of buffer
        an empty string (or string shorter than 'length') may be returned!
        """
    def read_uint8(self) -> int: ...
    def read_uint16(self) -> int: ...
    def read_uint24(self) -> int: ...
    def read_uint32(self) -> int: ...
    def read_uint64(self) -> int: ...
    def read_string(self) -> bytes: ...
    def read_length_encoded_integer(self):
        """
        Read a 'Length Coded Binary' number from the data buffer.

        Length coded numbers can be anywhere from 1 to 9 bytes depending
        on the value of the first byte.
        """
    def read_length_coded_string(self):
        """
        Read a 'Length Coded String' from the data buffer.

        A 'Length Coded String' consists first of a length coded
        (unsigned, positive) integer represented in 1-9 bytes followed by
        that many bytes of binary data.  (For example "cat" would be "3cat".)
        """
    def read_row(self, converters: tuple) -> tuple:
        """Parse the whole packet as one text-protocol result row."""
    def read_binary_row(self, colspecs: tuple) -> tuple:
        """Parse the whole packet as one binary-protocol result row."""
    def read_struct(self, fmt: str) -> tuple: ...
    def is_ok_packet(self) -> int: ...
    def is_eof_packet(self) -> int: ...
    def is_auth_switch_request(self) -> int: ...
    def is_extra_auth_data(self) -> int: ...
    def is_resultset_packet(self) -> int: ...
    def is_load_local_packet(self) -> int: ...
    def is_error_packet(self) -> int: ...
    def check_error(self): ...
    def raise_for_error(self): ...

class FieldDescriptorPacket(MysqlPacket):
    """
    A MysqlPacket that represents a specific column's metadata in the result.

    Parsing is automatically done and the results are exported via public
    attributes on the class such as: db, table_name, name, length, type_code.
    """

    table_name: str
    org_table: str
    name: str
    org_name: str
    charsetnr: int
    length: int
    type_code: int
    flags: int
    scale: int

    def __init__(self, data: bytes, encoding: str): ...
    def description(self):
        """Provides a 7-item tuple compatible with the Python PEP249 DB Spec."""
    def __str__(self): ...

class OKPacketWrapper:
    """
    OK Packet Wrapper. It uses an existing packet object, and wraps
    around it, exposing useful variables while still providing access
    to the original packet objects variables and methods.
    """

    server_status: int
    warning_count: int
    has_next: int
    message: bytes
    affected_rows: int
    insert_id: int

    def __init__(self, from_packet: MysqlPacket): ...
    def __getattr__(self, key): ...

class EOFPacketWrapper:
    """
    EOF Packet Wrapper. It uses an existing packet object, and wraps
    around it, exposing useful variables while still providing access
    to the original packet objects variables and methods.
    """

    server_status: int
    warning_count: int
    has_next: int

    def __init__(self, from_packet: MysqlPacket): ...
    def __getattr__(self, key): ...

class LoadLocalPacketWrapper:
    """
    Load Local Packet Wrapper. It uses an existing packet object, and wraps
    around it, exposing useful variables while still providing access
    to the original packet objects variables and methods.
    """

    filename: bytes

    def __init__(self, from_packet: MysqlPacket): ...
    def __getattr__(self, key): ...

def parse_rows_from_buffer(
    buf: bytearray,
    pos: int,
    buf_len: int,
    converters: tuple,
    seq_id: int,
    rows: list,
    deprecate_eof: bool = False,
):
    """Parse as many complete row packets as available in ``buf[pos:buf_len]``.

    Stops (without consuming) at the first packet that is incomplete, has a
    wrong sequence id, is an ERROR/EOF packet, is empty, or spans multiple
    wire packets (16MB). Parsed rows are appended to ``rows``.

    ``buf_len`` is the number of valid bytes (the bytearray's capacity may be
    larger when it is used as a receive buffer).

    Returns ``(new_pos, new_seq_id)``.
    """

def parse_binary_rows_from_buffer(
    buf: bytearray,
    pos: int,
    buf_len: int,
    colspecs: tuple,
    seq_id: int,
    rows: list,
    deprecate_eof: bool = False,
):
    """Binary-protocol counterpart of parse_rows_from_buffer."""

def skip_packets_from_buffer(buf: bytearray, pos: int, buf_len: int, seq_id: int, count: int):
    """Skip up to ``count`` complete packets without materializing them.

    Stops early at an incomplete packet, a sequence mismatch, a jumbo packet
    or an error packet (which the caller reads via read_packet to raise).

    Returns ``(new_pos, new_seq_id, skipped)``.
    """

def pack_bulk_rows(rows, nparams: int, encoding: str):
    """Serialize rows for MariaDB COM_STMT_BULK_EXECUTE.

    Returns ``(types_bytes, rows_bytes)`` or None when the rows are not
    bulk-compatible (a column is NULL in every row, or mixes value types).
    Each value is prefixed with an indicator byte (0 = value, 1 = NULL).
    """

def pack_binary_params(args: tuple, encoding: str) -> bytes:
    """Serialize COM_STMT_EXECUTE parameters.

    Returns null_bitmap + new_params_bound_flag(1) + types + values.
    """
