Use ReadWriteCloser for conns and streams

This commit is contained in:
mhchia
2019-09-05 23:24:17 +08:00
parent eac159c527
commit 10415cb956
9 changed files with 24 additions and 88 deletions

View File

@ -1,10 +1,11 @@
from abc import ABC, abstractmethod
from abc import abstractmethod
from libp2p.io.abc import ReadWriteCloser
from libp2p.stream_muxer.abc import IMuxedConn
from libp2p.typing import TProtocol
class INetStream(ABC):
class INetStream(ReadWriteCloser):
mplex_conn: IMuxedConn
@ -21,28 +22,6 @@ class INetStream(ABC):
:return: true if successful
"""
@abstractmethod
async def read(self, n: int = -1) -> bytes:
"""
reads from the underlying muxed_stream
:param n: number of bytes to read
:return: bytes of input
"""
@abstractmethod
async def write(self, data: bytes) -> int:
"""
write to the underlying muxed_stream
:return: number of bytes written
"""
@abstractmethod
async def close(self) -> bool:
"""
close the underlying muxed stream
:return: true if successful
"""
@abstractmethod
async def reset(self) -> bool:
"""