"""This is an automatically generated stub for `common.capnp`."""

from __future__ import annotations

from collections.abc import Awaitable, Iterator, Sequence
from contextlib import contextmanager
from enum import Enum
from io import BufferedWriter
from typing import (
    Any,
    BinaryIO,
    Generic,
    Literal,
    NamedTuple,
    Protocol,
    TypeVar,
    overload,
)

from capnp import _DynamicListBuilder

Value_F = TypeVar("Value_F")
Value_S = TypeVar("Value_S")

class IdInformation:
    @property
    def id(self) -> str: ...
    @property
    def name(self) -> str: ...
    @property
    def description(self) -> str: ...
    @staticmethod
    @contextmanager
    def from_bytes(
        data: bytes,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> Iterator[IdInformationReader]: ...
    @staticmethod
    def from_bytes_packed(
        data: bytes,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> IdInformationReader: ...
    @staticmethod
    def new_message(
        num_first_segment_words: int | None = None,
        allocate_seg_callable: Any = None,
        id: str | None = None,
        name: str | None = None,
        description: str | None = None,
    ) -> IdInformationBuilder: ...
    @staticmethod
    def read(
        file: BinaryIO,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> IdInformationReader: ...
    @staticmethod
    def read_packed(
        file: BinaryIO,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> IdInformationReader: ...
    def to_dict(self) -> dict[str, Any]: ...

class IdInformationReader(IdInformation):
    def as_builder(self) -> IdInformationBuilder: ...

class IdInformationBuilder(IdInformation):
    @property
    def id(self) -> str: ...
    @id.setter
    def id(self, value: str) -> None: ...
    @property
    def name(self) -> str: ...
    @name.setter
    def name(self, value: str) -> None: ...
    @property
    def description(self) -> str: ...
    @description.setter
    def description(self, value: str) -> None: ...
    @staticmethod
    def from_dict(dictionary: dict[str, Any]) -> IdInformationBuilder: ...
    def copy(self) -> IdInformationBuilder: ...
    def to_bytes(self) -> bytes: ...
    def to_bytes_packed(self) -> bytes: ...
    def to_segments(self) -> list[bytes]: ...
    def as_reader(self) -> IdInformationReader: ...
    @staticmethod
    def write(file: BufferedWriter) -> None: ...
    @staticmethod
    def write_packed(file: BufferedWriter) -> None: ...

class Identifiable(Protocol):
    class InfoResult(Protocol):
        id: str
        name: str
        description: str

    class InfoCallContext(Protocol):
        results: Identifiable.InfoResult

    def info(self) -> Awaitable[Identifiable.InfoResult]: ...
    class InfoRequest(Protocol):
        def send(self) -> Awaitable[Identifiable.InfoResult]: ...

    def info_request(self) -> InfoRequest: ...
    @classmethod
    def _new_client(cls, server: Identifiable.Server) -> Identifiable: ...
    class Server:
        class InfoResult(NamedTuple):
            id: str
            name: str
            description: str

        def info(
            self, _context: Identifiable.InfoCallContext, **kwargs: Any
        ) -> Awaitable[Identifiable.Server.InfoResult]: ...

class StructuredText:
    class Type(Enum):
        unstructured = "unstructured"
        json = "json"
        xml = "xml"
        toml = "toml"
        sturdyRef = "sturdyRef"

    class Structure:
        @property
        def none(self) -> None: ...
        @property
        def json(self) -> None: ...
        @property
        def xml(self) -> None: ...
        @property
        def toml(self) -> None: ...
        def which(self) -> Literal["none", "json", "xml", "toml"]: ...
        @staticmethod
        @contextmanager
        def from_bytes(
            data: bytes,
            traversal_limit_in_words: int | None = ...,
            nesting_limit: int | None = ...,
        ) -> Iterator[StructuredText.StructureReader]: ...
        @staticmethod
        def from_bytes_packed(
            data: bytes,
            traversal_limit_in_words: int | None = ...,
            nesting_limit: int | None = ...,
        ) -> StructuredText.StructureReader: ...
        @staticmethod
        def new_message(
            num_first_segment_words: int | None = None,
            allocate_seg_callable: Any = None,
            none: None | None = None,
            json: None | None = None,
            xml: None | None = None,
            toml: None | None = None,
        ) -> StructuredText.StructureBuilder: ...
        @staticmethod
        def read(
            file: BinaryIO,
            traversal_limit_in_words: int | None = ...,
            nesting_limit: int | None = ...,
        ) -> StructuredText.StructureReader: ...
        @staticmethod
        def read_packed(
            file: BinaryIO,
            traversal_limit_in_words: int | None = ...,
            nesting_limit: int | None = ...,
        ) -> StructuredText.StructureReader: ...
        def to_dict(self) -> dict[str, Any]: ...

    class StructureReader(StructuredText.Structure):
        def as_builder(self) -> StructuredText.StructureBuilder: ...

    class StructureBuilder(StructuredText.Structure):
        @property
        def none(self) -> None: ...
        @none.setter
        def none(self, value: None) -> None: ...
        @property
        def json(self) -> None: ...
        @json.setter
        def json(self, value: None) -> None: ...
        @property
        def xml(self) -> None: ...
        @xml.setter
        def xml(self, value: None) -> None: ...
        @property
        def toml(self) -> None: ...
        @toml.setter
        def toml(self, value: None) -> None: ...
        @staticmethod
        def from_dict(
            dictionary: dict[str, Any],
        ) -> StructuredText.StructureBuilder: ...
        def copy(self) -> StructuredText.StructureBuilder: ...
        def to_bytes(self) -> bytes: ...
        def to_bytes_packed(self) -> bytes: ...
        def to_segments(self) -> list[bytes]: ...
        def as_reader(self) -> StructuredText.StructureReader: ...
        @staticmethod
        def write(file: BufferedWriter) -> None: ...
        @staticmethod
        def write_packed(file: BufferedWriter) -> None: ...

    @property
    def value(self) -> str: ...
    @property
    def structure(self) -> StructuredText.Structure: ...
    @property
    def type(self) -> StructuredText.Type: ...
    def init(self, name: Literal["structure"]) -> StructuredText.Structure: ...
    @staticmethod
    @contextmanager
    def from_bytes(
        data: bytes,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> Iterator[StructuredTextReader]: ...
    @staticmethod
    def from_bytes_packed(
        data: bytes,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> StructuredTextReader: ...
    @staticmethod
    def new_message(
        num_first_segment_words: int | None = None,
        allocate_seg_callable: Any = None,
        value: str | None = None,
        structure: StructuredText.StructureBuilder | dict[str, Any] | None = None,
        type: StructuredText.Type
        | Literal["unstructured", "json", "xml", "toml", "sturdyRef"]
        | None = None,
    ) -> StructuredTextBuilder: ...
    @staticmethod
    def read(
        file: BinaryIO,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> StructuredTextReader: ...
    @staticmethod
    def read_packed(
        file: BinaryIO,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> StructuredTextReader: ...
    def to_dict(self) -> dict[str, Any]: ...

class StructuredTextReader(StructuredText):
    @property
    def structure(self) -> StructuredText.StructureReader: ...
    def as_builder(self) -> StructuredTextBuilder: ...

class StructuredTextBuilder(StructuredText):
    @property
    def value(self) -> str: ...
    @value.setter
    def value(self, value: str) -> None: ...
    @property
    def structure(self) -> StructuredText.StructureBuilder: ...
    @structure.setter
    def structure(
        self,
        value: StructuredText.Structure
        | StructuredText.StructureBuilder
        | StructuredText.StructureReader
        | dict[str, Any],
    ) -> None: ...
    @property
    def type(self) -> StructuredText.Type: ...
    @type.setter
    def type(
        self,
        value: StructuredText.Type
        | Literal["unstructured", "json", "xml", "toml", "sturdyRef"],
    ) -> None: ...
    @staticmethod
    def from_dict(dictionary: dict[str, Any]) -> StructuredTextBuilder: ...
    def init(self, name: Literal["structure"]) -> StructuredText.StructureBuilder: ...
    def copy(self) -> StructuredTextBuilder: ...
    def to_bytes(self) -> bytes: ...
    def to_bytes_packed(self) -> bytes: ...
    def to_segments(self) -> list[bytes]: ...
    def as_reader(self) -> StructuredTextReader: ...
    @staticmethod
    def write(file: BufferedWriter) -> None: ...
    @staticmethod
    def write_packed(file: BufferedWriter) -> None: ...

class Pair(Generic[Value_F, Value_S]):
    @property
    def fst(self) -> Value_F: ...
    @property
    def snd(self) -> Value_S: ...
    @staticmethod
    @contextmanager
    def from_bytes(
        data: bytes,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> Iterator[PairReader]: ...
    @staticmethod
    def from_bytes_packed(
        data: bytes,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> PairReader: ...
    @staticmethod
    def new_message(
        num_first_segment_words: int | None = None,
        allocate_seg_callable: Any = None,
        fst: Value_F | None = None,
        snd: Value_S | None = None,
    ) -> PairBuilder: ...
    @staticmethod
    def read(
        file: BinaryIO,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> PairReader: ...
    @staticmethod
    def read_packed(
        file: BinaryIO,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> PairReader: ...
    def to_dict(self) -> dict[str, Any]: ...

class PairReader(Pair, Generic[Value_F, Value_S]):
    def as_builder(self) -> PairBuilder: ...

class PairBuilder(Pair, Generic[Value_F, Value_S]):
    @property
    def fst(self) -> Value_F: ...
    @fst.setter
    def fst(self, value: Value_F) -> None: ...
    @property
    def snd(self) -> Value_S: ...
    @snd.setter
    def snd(self, value: Value_S) -> None: ...
    @staticmethod
    def from_dict(dictionary: dict[str, Any]) -> PairBuilder: ...
    def copy(self) -> PairBuilder: ...
    def to_bytes(self) -> bytes: ...
    def to_bytes_packed(self) -> bytes: ...
    def to_segments(self) -> list[bytes]: ...
    def as_reader(self) -> PairReader: ...
    @staticmethod
    def write(file: BufferedWriter) -> None: ...
    @staticmethod
    def write_packed(file: BufferedWriter) -> None: ...

class Value:
    @property
    def f64(self) -> float: ...
    @property
    def f32(self) -> float: ...
    @property
    def i64(self) -> int: ...
    @property
    def i32(self) -> int: ...
    @property
    def i16(self) -> int: ...
    @property
    def i8(self) -> int: ...
    @property
    def ui64(self) -> int: ...
    @property
    def ui32(self) -> int: ...
    @property
    def ui16(self) -> int: ...
    @property
    def ui8(self) -> int: ...
    @property
    def b(self) -> bool: ...
    @property
    def t(self) -> str: ...
    @property
    def d(self) -> bytes: ...
    @property
    def p(self) -> Any: ...
    @property
    def cap(self) -> Any: ...
    @property
    def lf64(self) -> Sequence[float]: ...
    @property
    def lf32(self) -> Sequence[float]: ...
    @property
    def li64(self) -> Sequence[int]: ...
    @property
    def li32(self) -> Sequence[int]: ...
    @property
    def li16(self) -> Sequence[int]: ...
    @property
    def li8(self) -> Sequence[int]: ...
    @property
    def lui64(self) -> Sequence[int]: ...
    @property
    def lui32(self) -> Sequence[int]: ...
    @property
    def lui16(self) -> Sequence[int]: ...
    @property
    def lui8(self) -> Sequence[int]: ...
    @property
    def lb(self) -> Sequence[bool]: ...
    @property
    def lt(self) -> Sequence[str]: ...
    @property
    def ld(self) -> Sequence[bytes]: ...
    @property
    def lcap(self) -> Sequence[Any]: ...
    @property
    def lpair(self) -> Sequence[Pair]: ...
    def which(
        self,
    ) -> Literal[
        "f64",
        "f32",
        "i64",
        "i32",
        "i16",
        "i8",
        "ui64",
        "ui32",
        "ui16",
        "ui8",
        "b",
        "t",
        "d",
        "p",
        "cap",
        "lf64",
        "lf32",
        "li64",
        "li32",
        "li16",
        "li8",
        "lui64",
        "lui32",
        "lui16",
        "lui8",
        "lb",
        "lt",
        "ld",
        "lcap",
        "lpair",
    ]: ...
    @staticmethod
    @contextmanager
    def from_bytes(
        data: bytes,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> Iterator[ValueReader]: ...
    @staticmethod
    def from_bytes_packed(
        data: bytes,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> ValueReader: ...
    @staticmethod
    def new_message(
        num_first_segment_words: int | None = None,
        allocate_seg_callable: Any = None,
        f64: float | None = None,
        f32: float | None = None,
        i64: int | None = None,
        i32: int | None = None,
        i16: int | None = None,
        i8: int | None = None,
        ui64: int | None = None,
        ui32: int | None = None,
        ui16: int | None = None,
        ui8: int | None = None,
        b: bool | None = None,
        t: str | None = None,
        d: bytes | None = None,
        p: Any | None = None,
        cap: Any | None = None,
        lf64: Sequence[float] | None = None,
        lf32: Sequence[float] | None = None,
        li64: Sequence[int] | None = None,
        li32: Sequence[int] | None = None,
        li16: Sequence[int] | None = None,
        li8: Sequence[int] | None = None,
        lui64: Sequence[int] | None = None,
        lui32: Sequence[int] | None = None,
        lui16: Sequence[int] | None = None,
        lui8: Sequence[int] | None = None,
        lb: Sequence[bool] | None = None,
        lt: Sequence[str] | None = None,
        ld: Sequence[bytes] | None = None,
        lcap: Sequence[Any] | None = None,
        lpair: Sequence[PairBuilder] | Sequence[dict[str, Any]] | None = None,
    ) -> ValueBuilder: ...
    @staticmethod
    def read(
        file: BinaryIO,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> ValueReader: ...
    @staticmethod
    def read_packed(
        file: BinaryIO,
        traversal_limit_in_words: int | None = ...,
        nesting_limit: int | None = ...,
    ) -> ValueReader: ...
    def to_dict(self) -> dict[str, Any]: ...

class ValueReader(Value):
    @property
    def lpair(self) -> Sequence[PairReader]: ...
    def as_builder(self) -> ValueBuilder: ...

class ValueBuilder(Value):
    @property
    def f64(self) -> float: ...
    @f64.setter
    def f64(self, value: float) -> None: ...
    @property
    def f32(self) -> float: ...
    @f32.setter
    def f32(self, value: float) -> None: ...
    @property
    def i64(self) -> int: ...
    @i64.setter
    def i64(self, value: int) -> None: ...
    @property
    def i32(self) -> int: ...
    @i32.setter
    def i32(self, value: int) -> None: ...
    @property
    def i16(self) -> int: ...
    @i16.setter
    def i16(self, value: int) -> None: ...
    @property
    def i8(self) -> int: ...
    @i8.setter
    def i8(self, value: int) -> None: ...
    @property
    def ui64(self) -> int: ...
    @ui64.setter
    def ui64(self, value: int) -> None: ...
    @property
    def ui32(self) -> int: ...
    @ui32.setter
    def ui32(self, value: int) -> None: ...
    @property
    def ui16(self) -> int: ...
    @ui16.setter
    def ui16(self, value: int) -> None: ...
    @property
    def ui8(self) -> int: ...
    @ui8.setter
    def ui8(self, value: int) -> None: ...
    @property
    def b(self) -> bool: ...
    @b.setter
    def b(self, value: bool) -> None: ...
    @property
    def t(self) -> str: ...
    @t.setter
    def t(self, value: str) -> None: ...
    @property
    def d(self) -> bytes: ...
    @d.setter
    def d(self, value: bytes) -> None: ...
    @property
    def p(self) -> Any: ...
    @p.setter
    def p(self, value: Any) -> None: ...
    @property
    def cap(self) -> Any: ...
    @cap.setter
    def cap(self, value: Any) -> None: ...
    @property
    def lf64(self) -> Sequence[float]: ...
    @lf64.setter
    def lf64(self, value: Sequence[float]) -> None: ...
    @property
    def lf32(self) -> Sequence[float]: ...
    @lf32.setter
    def lf32(self, value: Sequence[float]) -> None: ...
    @property
    def li64(self) -> Sequence[int]: ...
    @li64.setter
    def li64(self, value: Sequence[int]) -> None: ...
    @property
    def li32(self) -> Sequence[int]: ...
    @li32.setter
    def li32(self, value: Sequence[int]) -> None: ...
    @property
    def li16(self) -> Sequence[int]: ...
    @li16.setter
    def li16(self, value: Sequence[int]) -> None: ...
    @property
    def li8(self) -> Sequence[int]: ...
    @li8.setter
    def li8(self, value: Sequence[int]) -> None: ...
    @property
    def lui64(self) -> Sequence[int]: ...
    @lui64.setter
    def lui64(self, value: Sequence[int]) -> None: ...
    @property
    def lui32(self) -> Sequence[int]: ...
    @lui32.setter
    def lui32(self, value: Sequence[int]) -> None: ...
    @property
    def lui16(self) -> Sequence[int]: ...
    @lui16.setter
    def lui16(self, value: Sequence[int]) -> None: ...
    @property
    def lui8(self) -> Sequence[int]: ...
    @lui8.setter
    def lui8(self, value: Sequence[int]) -> None: ...
    @property
    def lb(self) -> Sequence[bool]: ...
    @lb.setter
    def lb(self, value: Sequence[bool]) -> None: ...
    @property
    def lt(self) -> Sequence[str]: ...
    @lt.setter
    def lt(self, value: Sequence[str]) -> None: ...
    @property
    def ld(self) -> Sequence[bytes]: ...
    @ld.setter
    def ld(self, value: Sequence[bytes]) -> None: ...
    @property
    def lcap(self) -> Sequence[Any]: ...
    @lcap.setter
    def lcap(self, value: Sequence[Any]) -> None: ...
    @property
    def lpair(self) -> Sequence[PairBuilder]: ...
    @lpair.setter
    def lpair(
        self,
        value: Sequence[Pair | PairBuilder | PairReader] | Sequence[dict[str, Any]],
    ) -> None: ...
    @staticmethod
    def from_dict(dictionary: dict[str, Any]) -> ValueBuilder: ...
    @overload
    def init(
        self: Any, name: Literal["lf64"], size: int = ...
    ) -> _DynamicListBuilder[float]: ...
    @overload
    def init(
        self: Any, name: Literal["lf32"], size: int = ...
    ) -> _DynamicListBuilder[float]: ...
    @overload
    def init(
        self: Any, name: Literal["li64"], size: int = ...
    ) -> _DynamicListBuilder[int]: ...
    @overload
    def init(
        self: Any, name: Literal["li32"], size: int = ...
    ) -> _DynamicListBuilder[int]: ...
    @overload
    def init(
        self: Any, name: Literal["li16"], size: int = ...
    ) -> _DynamicListBuilder[int]: ...
    @overload
    def init(
        self: Any, name: Literal["li8"], size: int = ...
    ) -> _DynamicListBuilder[int]: ...
    @overload
    def init(
        self: Any, name: Literal["lui64"], size: int = ...
    ) -> _DynamicListBuilder[int]: ...
    @overload
    def init(
        self: Any, name: Literal["lui32"], size: int = ...
    ) -> _DynamicListBuilder[int]: ...
    @overload
    def init(
        self: Any, name: Literal["lui16"], size: int = ...
    ) -> _DynamicListBuilder[int]: ...
    @overload
    def init(
        self: Any, name: Literal["lui8"], size: int = ...
    ) -> _DynamicListBuilder[int]: ...
    @overload
    def init(
        self: Any, name: Literal["lb"], size: int = ...
    ) -> _DynamicListBuilder[bool]: ...
    @overload
    def init(
        self: Any, name: Literal["lt"], size: int = ...
    ) -> _DynamicListBuilder[str]: ...
    @overload
    def init(
        self: Any, name: Literal["ld"], size: int = ...
    ) -> _DynamicListBuilder[bytes]: ...
    @overload
    def init(
        self: Any, name: Literal["lcap"], size: int = ...
    ) -> _DynamicListBuilder[Any]: ...
    @overload
    def init(
        self: Any, name: Literal["lpair"], size: int = ...
    ) -> _DynamicListBuilder[PairBuilder]: ...
    def init(self: Any, name: str, size: int = ...) -> Any: ...
    def copy(self) -> ValueBuilder: ...
    def to_bytes(self) -> bytes: ...
    def to_bytes_packed(self) -> bytes: ...
    def to_segments(self) -> list[bytes]: ...
    def as_reader(self) -> ValueReader: ...
    @staticmethod
    def write(file: BufferedWriter) -> None: ...
    @staticmethod
    def write_packed(file: BufferedWriter) -> None: ...

class Holder(Protocol):
    class ValueResult(Awaitable[ValueResult], Protocol):
        value: Any

    class ValueResultsBuilder(Protocol):
        value: Any

    class ValueCallContext(Protocol):
        results: Holder.ValueResultsBuilder

    def value(self) -> ValueResult: ...
    class ValueRequest(Protocol):
        def send(self) -> Holder.ValueResult: ...

    def value_request(self) -> ValueRequest: ...
    @classmethod
    def _new_client(cls, server: Holder.Server) -> Holder: ...
    class Server:
        def value(
            self, _context: Holder.ValueCallContext, **kwargs: Any
        ) -> Awaitable[Any]: ...

class IdentifiableHolder(Identifiable, Holder, Protocol):
    @classmethod
    def _new_client(
        cls, server: IdentifiableHolder.Server | Holder.Server | Identifiable.Server
    ) -> IdentifiableHolder: ...
    class Server(Identifiable.Server, Holder.Server): ...
