py-libp2p/libp2p/io/abc.py
Alex Stokes 8e8318aa5c
Introduces IO abstractions apart from asyncio or those attached to IRawConnection
Also adds `msgio` utilities to mirror the Go implementation
2019-09-03 21:59:50 -07:00

35 lines
499 B
Python

from abc import ABC, abstractmethod
class Closer(ABC):
async def close(self) -> None:
...
class Reader(ABC):
@abstractmethod
async def read(self, n: int = -1) -> bytes:
...
class Writer(ABC):
@abstractmethod
async def write(self, data: bytes) -> int:
...
class WriteCloser(Writer, Closer):
pass
class ReadCloser(Reader, Closer):
pass
class ReadWriter(Reader, Writer):
pass
class ReadWriteCloser(Reader, Writer, Closer):
pass