1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
"""ledgercomm.comm module."""
from abc import ABCMeta, abstractmethod
from typing import Tuple
class Comm(metaclass=ABCMeta):
"""Abstract class for communication interface."""
@abstractmethod
def open(self) -> None:
"""Just open the interface."""
raise NotImplementedError
@abstractmethod
def send(self, data: bytes) -> int:
"""Allow to send raw bytes from the interface."""
raise NotImplementedError
@abstractmethod
def recv(self) -> Tuple[int, bytes]:
"""Allow to receive raw bytes from the interface."""
raise NotImplementedError
@abstractmethod
def exchange(self, data: bytes) -> Tuple[int, bytes]:
"""Allow to send and receive raw bytes from the interface."""
raise NotImplementedError
@abstractmethod
def close(self) -> None:
"""Just close the interface."""
raise NotImplementedError
|