File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change 8
8
Types needed for type annotation that are not in `typing`
9
9
10
10
11
- * Author(s): Alec Delaney, Dan Halbert
11
+ * Author(s): Alec Delaney, Dan Halbert, Randy Hudson
12
12
"""
13
13
14
14
__version__ = "0.0.0-auto.0"
15
15
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Typing.git"
16
16
17
- from typing import Union
17
+ from typing import Union , Protocol , Optional
18
18
from array import array
19
19
20
20
ReadableBuffer = Union [bytes , bytearray , memoryview , array ]
31
31
* `memoryview`
32
32
* `array.array`
33
33
"""
34
+
35
+
36
+ class ByteStream (Protocol ):
37
+ """Protocol for basic I/O operations on a byte stream.
38
+ Classes which implement this protocol include
39
+ * `io.BytesIO`
40
+ * `io.FileIO` (for a file open in binary mode)
41
+ * `busio.UART`
42
+ * `usb_cdc.Serial`
43
+ """
44
+
45
+ def read (self , count : Optional [int ] = None , / ) -> Optional [bytes ]:
46
+ """Read ``count`` bytes from the stream.
47
+ If ``count`` bytes are not immediately available,
48
+ or if the parameter is not specified in the call,
49
+ the outcome is implementation-dependent.
50
+ """
51
+ ...
52
+
53
+ def write (self , buf : ReadableBuffer , / ) -> Optional [int ]:
54
+ """Write the bytes in ``buf`` to the stream."""
55
+ ...
You can’t perform that action at this time.
0 commit comments