add typing to mplex

This commit is contained in:
Chih Cheng Liang
2019-08-02 17:53:51 +08:00
parent 36b7e8ded9
commit 239a5c88fb
3 changed files with 53 additions and 12 deletions

View File

@ -1,3 +1,4 @@
import asyncio
from abc import ABC, abstractmethod
@ -6,6 +7,13 @@ class IRawConnection(ABC):
A Raw Connection provides a Reader and a Writer
"""
initiator: bool
# TODO: reader and writer shouldn't be exposed.
# Need better API for the consumers
reader: asyncio.StreamReader
writer: asyncio.StreamWriter
@abstractmethod
async def write(self, data: bytes) -> None:
pass
@ -13,3 +21,11 @@ class IRawConnection(ABC):
@abstractmethod
async def read(self) -> bytes:
pass
@abstractmethod
def close(self) -> None:
pass
@abstractmethod
def next_stream_id(self) -> int:
pass