from _typeshed import ReadableBuffer, WriteableBuffer
from typing import Any, TypeAlias

from . import brotli as brotli
from . import bzip2 as bzip2
from . import deflate as deflate
from . import experimental as experimental
from . import gzip as gzip
from . import lz4 as lz4
from . import snappy as snappy
from . import xz as xz
from . import zlib as zlib
from . import zstd as zstd

__version__: str

class CompressionError(Exception): ...
class DecompressionError(Exception): ...

class Buffer:
    def __init__(self, data: BufferInput | None = None, copy: bool | None = None) -> None: ...
    def ensure_aligned_view(self) -> None: ...
    def get_view_reference(self) -> object | None: ...
    def get_view_reference_count(self) -> int | None: ...
    def len(self) -> int: ...
    def write(self, input: BufferInput) -> int: ...
    def read(self, n_bytes: int | None = None) -> bytes: ...
    def readinto(self, output: BufferOutput) -> int: ...
    def seek(self, position: int, whence: int | None = None) -> int: ...
    def seekable(self) -> bool: ...
    def tell(self) -> int: ...
    def set_len(self, size: int) -> None: ...
    def truncate(self) -> None: ...
    def __len__(self) -> int: ...
    def __contains__(self, x: BufferInput) -> bool: ...
    def __repr__(self) -> str: ...
    def __eq__(self, other: Buffer) -> bool: ...
    def __bool__(self) -> bool: ...

class File:
    def __init__(
        self,
        path: str,
        read: bool | None = None,
        write: bool | None = None,
        truncate: bool | None = None,
        append: bool | None = None,
    ) -> None: ...
    def write(self, input: BufferInput) -> int: ...
    def read(self, n_bytes: int | None = None) -> bytes: ...
    def readinto(self, output: BufferOutput) -> int: ...
    def seek(self, position: int, whence: int | None = None) -> int: ...
    def seekable(self) -> bool: ...
    def tell(self) -> int: ...
    def set_len(self, size: int) -> None: ...
    def truncate(self) -> None: ...
    def len(self) -> int: ...
    def __repr__(self) -> str: ...
    def __bool__(self) -> bool: ...
    def __len__(self) -> int: ...

BufferInput: TypeAlias = ReadableBuffer | Buffer | File
BufferOutput: TypeAlias = WriteableBuffer | Buffer | File
# Retained as the public alias used by earlier cramjam stubs.
BufferProtocol: TypeAlias = BufferInput
