Skip to content
proto.pyi 1.41 KiB
Newer Older
Dom Sekotill's avatar
Dom Sekotill committed
from asyncio import StreamReader
from enum import Enum
from typing import IO
from typing import ClassVar
from typing import NamedTuple

__all__ = ["LittleEndianSignedInt32", "Type", "Packet", "random_request_id"]


class LittleEndianSignedInt32(int):

	MIN: ClassVar[int]
	MAX: ClassVar[int]

	@classmethod
	async def aread(cls, reader: StreamReader) -> LittleEndianSignedInt32: ...

	@classmethod
	def read(cls, file: IO[bytes]) -> LittleEndianSignedInt32: ...

	def __bytes__(self) -> bytes: ...


class Type(LittleEndianSignedInt32, Enum):

	SERVERDATA_AUTH = ...
	SERVERDATA_AUTH_RESPONSE = ...
	SERVERDATA_EXECCOMMAND = ...
	SERVERDATA_RESPONSE_VALUE = ...

	@classmethod
	async def aread(cls, reader: StreamReader, *, prefix: str = ...) -> Type: ...

	@classmethod
	def read(cls, file: IO[bytes], *, prefix: str = ...) -> Type: ...


class Packet(NamedTuple):

	id: LittleEndianSignedInt32
	type: Type
	payload: bytes
	terminator: ClassVar[bytes]

	@classmethod
	def make_command(cls, *_: str, encoding: str = ...) -> Packet: ...

	@classmethod
	def make_login(cls, passwd: str, *, encoding: str = ...) -> Packet: ...

	@classmethod
	async def aread(cls, reader: StreamReader) -> LittleEndianSignedInt32: ...

	@classmethod
	def read(cls, file: IO[bytes]) -> LittleEndianSignedInt32: ...

	def __bytes__(self) -> bytes: ...
	def __radd__(self, other: Packet|None) -> Packet: ...


def random_request_id() -> LittleEndianSignedInt32: ...