mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-10 07:00:54 +00:00
Introduces IO abstractions apart from asyncio or those attached to IRawConnection
Also adds `msgio` utilities to mirror the Go implementation
This commit is contained in:
34
libp2p/io/abc.py
Normal file
34
libp2p/io/abc.py
Normal file
@ -0,0 +1,34 @@
|
||||
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
|
||||
Reference in New Issue
Block a user