mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Use ReadWriteCloser for conns and streams
This commit is contained in:
@ -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:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user