Files
py-libp2p/libp2p/stream_muxer/muxed_stream_interface.py
Chih Cheng Liang 4c9a930f84 stream_muxer done
2019-08-05 10:45:47 +08:00

45 lines
1010 B
Python

from abc import ABC, abstractmethod
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
class IMuxedStream(ABC):
mplex_conn: IMuxedConn
@abstractmethod
async def read(self) -> bytes:
"""
reads from the underlying muxed_conn
:return: bytes of input
"""
@abstractmethod
async def write(self, data: bytes) -> int:
"""
writes to the underlying muxed_conn
:return: number of bytes written
"""
@abstractmethod
async def close(self) -> bool:
"""
close the underlying muxed_conn
:return: true if successful
"""
@abstractmethod
async def reset(self) -> bool:
"""
closes both ends of the stream
tells this remote side to hang up
:return: true if successful
"""
@abstractmethod
def set_deadline(self, ttl: float) -> bool:
"""
set deadline for muxed stream
:return: a new stream
"""