# Path: grpclib/const.py
# class Status(enum.Enum):
#     """Predefined gRPC status codes represented as enum
# 
#     See also: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
#     """
#     #: The operation completed successfully
#     OK = 0
#     #: The operation was cancelled (typically by the caller)
#     CANCELLED = 1
#     #: Generic status to describe error when it can't be described using
#     #: other statuses
#     UNKNOWN = 2
#     #: Client specified an invalid argument
#     INVALID_ARGUMENT = 3
#     #: Deadline expired before operation could complete
#     DEADLINE_EXCEEDED = 4
#     #: Some requested entity was not found
#     NOT_FOUND = 5
#     #: Some entity that we attempted to create already exists
#     ALREADY_EXISTS = 6
#     #: The caller does not have permission to execute the specified operation
#     PERMISSION_DENIED = 7
#     #: Some resource has been exhausted, perhaps a per-user quota, or perhaps
#     #: the entire file system is out of space
#     RESOURCE_EXHAUSTED = 8
#     #: Operation was rejected because the system is not in a state required
#     #: for the operation's execution
#     FAILED_PRECONDITION = 9
#     #: The operation was aborted
#     ABORTED = 10
#     #: Operation was attempted past the valid range
#     OUT_OF_RANGE = 11
#     #: Operation is not implemented or not supported/enabled in this service
#     UNIMPLEMENTED = 12
#     #: Internal errors
#     INTERNAL = 13
#     #: The service is currently unavailable
#     UNAVAILABLE = 14
#     #: Unrecoverable data loss or corruption
#     DATA_LOSS = 15
#     #: The request does not have valid authentication credentials for the
#     #: operation
#     UNAUTHENTICATED = 16
# 
# Path: grpclib/metadata.py
# USER_AGENT = (
#     'grpc-python-grpclib/{lib_ver} ({sys}; {py}/{py_ver})'
#     .format(
#         lib_ver=__version__,
#         sys=platform.system(),
#         py=platform.python_implementation(),
#         py_ver=platform.python_version(),
#     )
#     .lower()
# )
# _UNITS = {
#     'H': 60 * 60,
#     'M': 60,
#     'S': 1,
#     'm': 10 ** -3,
#     'u': 10 ** -6,
#     'n': 10 ** -9,
# }
# _TIMEOUT_RE = re.compile(r'^(\d+)([{}])$'.format(''.join(_UNITS)))
# _STATUS_DETAILS_KEY = 'grpc-status-details-bin'
# _UNQUOTED = ''.join([chr(i) for i in range(0x20, 0x24 + 1)]
#                     + [chr(i) for i in range(0x26, 0x7E + 1)])
# _KEY_RE = re.compile(r'^[0-9a-z_.\-]+$')
# _VALUE_RE = re.compile(r'^[ !-~]+$')  # 0x20-0x7E - space and printable ASCII
# _SPECIAL = {
#     'te',
#     'content-type',
#     'user-agent',
# }
# def decode_timeout(value: str) -> float:
# def encode_timeout(timeout: float) -> str:
#     def __init__(self, *, _timestamp: float) -> None:
#     def __lt__(self, other: object) -> bool:
#     def __eq__(self, other: object) -> bool:
#     def from_headers(cls, headers: _Headers) -> Optional['Deadline']:
#     def from_timeout(cls, timeout: float) -> 'Deadline':
#     def time_remaining(self) -> float:
# def encode_grpc_message(message: str) -> str:
# def decode_grpc_message(value: str) -> str:
# def decode_bin_value(value: bytes) -> bytes:
# def decode_metadata(headers: _Headers) -> _Metadata:
# def encode_bin_value(value: bytes) -> bytes:
# def encode_metadata(metadata: _MetadataLike) -> _Headers:
# class Deadline:


from typing import TYPE_CHECKING, Type, TypeVar, Tuple, FrozenSet, Dict
from typing import Optional, Callable, Any, Collection, List, Coroutine
from itertools import chain
from collections import defaultdict
from .const import Status
from .metadata import Deadline, _Metadata
    from .stream import _SendType, _RecvType
    from ._typing import IEventsTarget, IServerMethodFunc  # noqa
    from .protocol import Peer
    @_dispatches(SendRequest)
    async def send_request(
        self,
        metadata: _Metadata,
        *,
        method_name: str,
        deadline: Optional[Deadline],
        content_type: str,
    ) -> Tuple[_Metadata]:
        return await self.__dispatch__(SendRequest(  # type: ignore
            metadata=metadata,
            method_name=method_name,
            deadline=deadline,
            content_type=content_type,
        ))

    @_dispatches(RecvInitialMetadata)
    async def recv_initial_metadata(
        self,
        metadata: _Metadata,
    ) -> Tuple[_Metadata]:
        return await self.__dispatch__(RecvInitialMetadata(  # type: ignore
            metadata=metadata,
        ))

    @_dispatches(RecvTrailingMetadata)
    async def recv_trailing_metadata(
        self,
        metadata: _Metadata,
        *,

# Path: grpclib/const.py
# class Status(enum.Enum):
#     """Predefined gRPC status codes represented as enum
# 
#     See also: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
#     """
#     #: The operation completed successfully
#     OK = 0
#     #: The operation was cancelled (typically by the caller)
#     CANCELLED = 1
#     #: Generic status to describe error when it can't be described using
#     #: other statuses
#     UNKNOWN = 2
#     #: Client specified an invalid argument
#     INVALID_ARGUMENT = 3
#     #: Deadline expired before operation could complete
#     DEADLINE_EXCEEDED = 4
#     #: Some requested entity was not found
#     NOT_FOUND = 5
#     #: Some entity that we attempted to create already exists
#     ALREADY_EXISTS = 6
#     #: The caller does not have permission to execute the specified operation
#     PERMISSION_DENIED = 7
#     #: Some resource has been exhausted, perhaps a per-user quota, or perhaps
#     #: the entire file system is out of space
#     RESOURCE_EXHAUSTED = 8
#     #: Operation was rejected because the system is not in a state required
#     #: for the operation's execution
#     FAILED_PRECONDITION = 9
#     #: The operation was aborted
#     ABORTED = 10
#     #: Operation was attempted past the valid range
#     OUT_OF_RANGE = 11
#     #: Operation is not implemented or not supported/enabled in this service
#     UNIMPLEMENTED = 12
#     #: Internal errors
#     INTERNAL = 13
#     #: The service is currently unavailable
#     UNAVAILABLE = 14
#     #: Unrecoverable data loss or corruption
#     DATA_LOSS = 15
#     #: The request does not have valid authentication credentials for the
#     #: operation
#     UNAUTHENTICATED = 16
# 
# Path: grpclib/metadata.py
# USER_AGENT = (
#     'grpc-python-grpclib/{lib_ver} ({sys}; {py}/{py_ver})'
#     .format(
#         lib_ver=__version__,
#         sys=platform.system(),
#         py=platform.python_implementation(),
#         py_ver=platform.python_version(),
#     )
#     .lower()
# )
# _UNITS = {
#     'H': 60 * 60,
#     'M': 60,
#     'S': 1,
#     'm': 10 ** -3,
#     'u': 10 ** -6,
#     'n': 10 ** -9,
# }
# _TIMEOUT_RE = re.compile(r'^(\d+)([{}])$'.format(''.join(_UNITS)))
# _STATUS_DETAILS_KEY = 'grpc-status-details-bin'
# _UNQUOTED = ''.join([chr(i) for i in range(0x20, 0x24 + 1)]
#                     + [chr(i) for i in range(0x26, 0x7E + 1)])
# _KEY_RE = re.compile(r'^[0-9a-z_.\-]+$')
# _VALUE_RE = re.compile(r'^[ !-~]+$')  # 0x20-0x7E - space and printable ASCII
# _SPECIAL = {
#     'te',
#     'content-type',
#     'user-agent',
# }
# def decode_timeout(value: str) -> float:
# def encode_timeout(timeout: float) -> str:
#     def __init__(self, *, _timestamp: float) -> None:
#     def __lt__(self, other: object) -> bool:
#     def __eq__(self, other: object) -> bool:
#     def from_headers(cls, headers: _Headers) -> Optional['Deadline']:
#     def from_timeout(cls, timeout: float) -> 'Deadline':
#     def time_remaining(self) -> float:
# def encode_grpc_message(message: str) -> str:
# def decode_grpc_message(value: str) -> str:
# def decode_bin_value(value: bytes) -> bytes:
# def decode_metadata(headers: _Headers) -> _Metadata:
# def encode_bin_value(value: bytes) -> bytes:
# def encode_metadata(metadata: _MetadataLike) -> _Headers:
# class Deadline:


# Path: grpclib/events.py
from typing import TYPE_CHECKING, Type, TypeVar, Tuple, FrozenSet, Dict
from typing import Optional, Callable, Any, Collection, List, Coroutine
from itertools import chain
from collections import defaultdict
from .const import Status
from .metadata import Deadline, _Metadata
    from .stream import _SendType, _RecvType
    from ._typing import IEventsTarget, IServerMethodFunc  # noqa
    from .protocol import Peer

    @_dispatches(SendRequest)
    async def send_request(
        self,
        metadata: _Metadata,
        *,
        method_name: str,
        deadline: Optional[Deadline],
        content_type: str,
    ) -> Tuple[_Metadata]:
        return await self.__dispatch__(SendRequest(  # type: ignore
            metadata=metadata,
            method_name=method_name,
            deadline=deadline,
            content_type=content_type,
        ))

    @_dispatches(RecvInitialMetadata)
    async def recv_initial_metadata(
        self,
        metadata: _Metadata,
    ) -> Tuple[_Metadata]:
        return await self.__dispatch__(RecvInitialMetadata(  # type: ignore
            metadata=metadata,
        ))

    @_dispatches(RecvTrailingMetadata)
    async def recv_trailing_metadata(
        self,
        metadata: _Metadata,
        *,

        status: Status,