py-libp2p/libp2p/network/connection/raw_connection_interface.py
Chih Cheng Liang e763f57930
run isort
2019-08-05 11:47:23 +08:00

32 lines
613 B
Python

from abc import ABC, abstractmethod
import asyncio
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
@abstractmethod
async def read(self) -> bytes:
pass
@abstractmethod
def close(self) -> None:
pass
@abstractmethod
def next_stream_id(self) -> int:
pass