from typing import Any, Type, TypeVar, Generic, overload

T = TypeVar("T")

class Decoder(Generic[T]):
    @overload
    def __init__(self: Decoder[Any]) -> None: ...
    @overload
    def __init__(self: Decoder[T], type: Type[T] = ...) -> None: ...
    def decode(self, data: bytes) -> T: ...

class Encoder:
    def __init__(self, *, write_buffer_size: int = ...): ...
    def encode(self, obj: Any) -> bytes: ...

@overload
def decode(buf: bytes) -> Any: ...
@overload
def decode(buf: bytes, type: Type[T] = ...) -> T: ...
def encode(obj: Any) -> bytes: ...
