py-libp2p/libp2p/network/stream/net_stream_interface.py

30 lines
677 B
Python
Raw Normal View History

from abc import abstractmethod
2018-11-12 05:04:57 +08:00
from libp2p.io.abc import ReadWriteCloser
from libp2p.stream_muxer.abc import IMuxedConn
from libp2p.typing import TProtocol
2019-07-28 14:30:15 +08:00
2019-01-10 02:38:56 +08:00
class INetStream(ReadWriteCloser):
2018-11-12 05:04:57 +08:00
2019-07-30 15:31:02 +08:00
mplex_conn: IMuxedConn
2019-07-28 14:30:15 +08:00
2018-11-12 05:04:57 +08:00
@abstractmethod
def get_protocol(self) -> TProtocol:
2018-11-12 05:04:57 +08:00
"""
:return: protocol id that stream runs on
"""
@abstractmethod
def set_protocol(self, protocol_id: TProtocol) -> bool:
2018-11-12 05:04:57 +08:00
"""
:param protocol_id: protocol id that stream runs on
:return: true if successful
"""
2019-08-27 02:38:39 +08:00
@abstractmethod
async def reset(self) -> bool:
"""
Close both ends of the stream.
"""