from __future__ import annotations

from collections.abc import AsyncIterator, Coroutine, Iterator
from typing import Any, Generic, TypeVar

import numpy as np

T = TypeVar("T", int, float, np.integer, np.floating)

class NumericRingBuffer(Generic[T]):
    def __init__(
        self, max_capacity: int, dtype: np.dtype | type[T], disable_async: bool = False
    ) -> None: ...
    def raw(self, copy: bool = True) -> np.ndarray: ...
    def unwrapped(self) -> np.ndarray: ...
    def overwrite_latest(self, item: T, increment_count: bool = False) -> None: ...
    def insert(self, item: T) -> None: ...

    # Accepts any 1-D numpy array of numeric dtype; runtime enforces dtype compatibility
    def insert_batch(self, items: np.ndarray) -> None: ...
    def contains(self, item: T) -> bool: ...
    def consume(self) -> T: ...
    def consume_all(self) -> np.ndarray: ...
    def consume_iterable(self) -> Iterator[T]: ...
    def aconsume(self) -> Coroutine[Any, Any, T]: ...
    def aconsume_iterable(self) -> AsyncIterator[T]: ...
    def peekright(self) -> T: ...
    def peekleft(self) -> T: ...
    def clear(self) -> None: ...
    def is_empty(self) -> bool: ...
    def is_full(self) -> bool: ...
    def __contains__(self, item: object) -> bool: ...
    def __len__(self) -> int: ...
    def __getitem__(self, idx: int) -> T: ...


def _contains_u64(ringbuffer: NumericRingBuffer[Any], item: int) -> bool: ...
def _insert_u64(ringbuffer: NumericRingBuffer[Any], item: int) -> None: ...
