py-libp2p/libp2p/typing.py
mhchia 4f7bb30d82
Add INetStream to type StreamReader
TODO: Make stream readers implement `Reader`
2019-09-03 22:59:44 +08:00

13 lines
486 B
Python

from typing import TYPE_CHECKING, Awaitable, Callable, NewType, Union
from libp2p.network.connection.raw_connection_interface import IRawConnection
if TYPE_CHECKING:
from libp2p.network.stream.net_stream_interface import INetStream # noqa: F401
from libp2p.stream_muxer.abc import IMuxedStream # noqa: F401
TProtocol = NewType("TProtocol", str)
StreamHandlerFn = Callable[["INetStream"], Awaitable[None]]
StreamReader = Union["IMuxedStream", "INetStream", IRawConnection]