Refactor MsgIOReadWriter

- Abstract it as `MsgReadWriter`
- `MsgIOReadWriter` as a subclass of `MsgReadWriter`
This commit is contained in:
mhchia
2020-02-17 17:30:29 +08:00
parent ea645f0bd6
commit 874c6bbca4
2 changed files with 44 additions and 43 deletions

View File

@ -32,3 +32,23 @@ class ReadWriter(Reader, Writer):
class ReadWriteCloser(Reader, Writer, Closer):
pass
class MsgReader(ABC):
@abstractmethod
async def read_msg(self) -> bytes:
...
@abstractmethod
async def next_msg_len(self) -> int:
...
class MsgWriter(ABC):
@abstractmethod
async def write_msg(self, msg: bytes) -> None:
...
class MsgReadWriter(MsgReader, MsgWriter):
pass