forked from pybricks/pybricks-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessaging.pyi
More file actions
49 lines (40 loc) · 1.58 KB
/
Copy pathmessaging.pyi
File metadata and controls
49 lines (40 loc) · 1.58 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# SPDX-License-Identifier: MIT
# Copyright (c) 2020 The Pybricks Authors
from abc import abstractmethod
from typing import Callable, Generic, Optional, TypeVar
T = TypeVar("T")
class Connection:
@abstractmethod
def read_from_mailbox(self, name: str) -> bytes: ...
@abstractmethod
def send_to_mailbox(self, name: str, data: bytes) -> None: ...
@abstractmethod
def wait_for_mailbox_update(self, name: str) -> None: ...
class Mailbox(Generic[T]):
def __init__(
self,
name: str,
connection: Connection,
encode: Optional[Callable[[T], bytes]] = None,
decode: Optional[Callable[[bytes], T]] = None,
): ...
def read(self) -> T: ...
def send(self, value: T, brick: Optional[str] = None) -> None: ...
def wait(self) -> None: ...
def wait_new(self) -> T: ...
class LogicMailbox(Mailbox[bool]):
def __init__(self, name, connection: Connection): ...
class NumericMailbox(Mailbox[float]):
def __init__(self, name, connection: Connection): ...
class TextMailbox(Mailbox[str]):
def __init__(self, name, connection: Connection): ...
class BluetoothMailboxServer(Connection):
def __enter__(self) -> BluetoothMailboxServer: ...
def __exit__(self, type, value, traceback) -> None: ...
def wait_for_connection(self, count: int = 1) -> None: ...
def server_close(self) -> None: ...
class BluetoothMailboxClient(Connection):
def __enter__(self) -> BluetoothMailboxClient: ...
def __exit__(self, type, value, traceback) -> None: ...
def connect(self, brick: str) -> None: ...
def close(self) -> None: ...