2019-09-05 23:24:17 +08:00
|
|
|
from abc import abstractmethod
|
2018-11-12 05:04:57 +08:00
|
|
|
|
2019-09-05 23:24:17 +08:00
|
|
|
from libp2p.io.abc import ReadWriteCloser
|
2019-08-05 11:17:38 +08:00
|
|
|
from libp2p.stream_muxer.abc import IMuxedConn
|
2019-08-11 16:47:54 +08:00
|
|
|
from libp2p.typing import TProtocol
|
2019-07-28 14:30:15 +08:00
|
|
|
|
2019-01-10 02:38:56 +08:00
|
|
|
|
2019-09-05 23:24:17 +08:00
|
|
|
class INetStream(ReadWriteCloser):
|
2018-11-12 05:04:57 +08:00
|
|
|
|
2019-09-15 21:41:29 +08:00
|
|
|
muxed_conn: IMuxedConn
|
2019-07-28 14:30:15 +08:00
|
|
|
|
2018-11-12 05:04:57 +08:00
|
|
|
@abstractmethod
|
2019-08-11 16:47:54 +08:00
|
|
|
def get_protocol(self) -> TProtocol:
|
2018-11-12 05:04:57 +08:00
|
|
|
"""
|
|
|
|
:return: protocol id that stream runs on
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
2019-09-14 21:47:49 +08:00
|
|
|
def set_protocol(self, protocol_id: TProtocol) -> None:
|
2018-11-12 05:04:57 +08:00
|
|
|
"""
|
|
|
|
:param protocol_id: protocol id that stream runs on
|
|
|
|
"""
|
|
|
|
|
2019-08-27 02:38:39 +08:00
|
|
|
@abstractmethod
|
2019-09-09 15:45:35 +08:00
|
|
|
async def reset(self) -> None:
|
2019-08-27 02:38:39 +08:00
|
|
|
"""
|
|
|
|
Close both ends of the stream.
|
|
|
|
"""
|