up-py-rs 0.0.4__pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
up_py_rs/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .up_py_rs import *
2
+
3
+ __doc__ = up_py_rs.__doc__
4
+ if hasattr(up_py_rs, "__all__"):
5
+ __all__ = up_py_rs.__all__
up_py_rs/__init__.pyi ADDED
@@ -0,0 +1,243 @@
1
+ """
2
+ Type stubs for up_py_rs - Python bindings for up-rust (uProtocol).
3
+
4
+ This file provides type hints and IDE support for the up_py_rs module.
5
+ """
6
+
7
+ from typing import Optional, Callable
8
+
9
+ # Top-level classes
10
+
11
+ class UMessage:
12
+ """
13
+ Represents a complete uProtocol message.
14
+
15
+ UMessage encapsulates both the payload and metadata for a uProtocol communication.
16
+ It is typically received by listener callbacks.
17
+ """
18
+
19
+ def extract_string(self) -> Optional[str]:
20
+ """
21
+ Extract string value from the message payload.
22
+
23
+ Returns:
24
+ The extracted string if successful, None if the message
25
+ doesn't contain a string value.
26
+
27
+ Example:
28
+ >>> text = message.extract_string()
29
+ >>> if text:
30
+ ... print(f"Received: {text}")
31
+ """
32
+ ...
33
+
34
+
35
+ class StaticUriProvider:
36
+ """
37
+ Provides URI information for uProtocol entities.
38
+
39
+ StaticUriProvider creates and manages URIs for identifying entities
40
+ in the uProtocol network. It combines an authority (device/vehicle name),
41
+ entity ID, and version to create unique identifiers.
42
+ """
43
+
44
+ def __init__(self, authority: str, entity_id: int, version: int) -> None:
45
+ """
46
+ Create a new StaticUriProvider.
47
+
48
+ Args:
49
+ authority: The authority name identifying the device/vehicle
50
+ (e.g., "my-vehicle", "sensor-001").
51
+ entity_id: The entity ID (0 to 2^32-1, e.g., 0xa34b).
52
+ version: The version number (0 to 255, e.g., 0x01).
53
+
54
+ Example:
55
+ >>> from up_py_rs import StaticUriProvider
56
+ >>> provider = StaticUriProvider("my-vehicle", 0xa34b, 0x01)
57
+ """
58
+ ...
59
+
60
+
61
+ # Submodule: communication
62
+
63
+ class communication:
64
+ """Communication module containing publishers and payloads."""
65
+
66
+ class UPayload:
67
+ """
68
+ Represents a message payload in uProtocol.
69
+
70
+ UPayload encapsulates the data being transmitted in a uProtocol message.
71
+ It can be created from strings or raw bytes.
72
+ """
73
+
74
+ @staticmethod
75
+ def from_string(value: str) -> 'communication.UPayload':
76
+ """
77
+ Create a UPayload from a string value.
78
+
79
+ Args:
80
+ value: The string content to wrap in the payload.
81
+
82
+ Returns:
83
+ A new payload instance containing the string.
84
+
85
+ Raises:
86
+ Exception: If the payload creation fails.
87
+
88
+ Example:
89
+ >>> from up_py_rs.communication import UPayload
90
+ >>> payload = UPayload.from_string("Hello, World!")
91
+ """
92
+ ...
93
+
94
+ @staticmethod
95
+ def from_bytes(data: list[int]) -> 'communication.UPayload':
96
+ """
97
+ Create a UPayload from raw bytes.
98
+
99
+ Args:
100
+ data: A list of bytes (0-255) to wrap in the payload.
101
+
102
+ Returns:
103
+ A new payload instance containing the binary data.
104
+
105
+ Example:
106
+ >>> from up_py_rs.communication import UPayload
107
+ >>> payload = UPayload.from_bytes([72, 101, 108, 108, 111])
108
+ """
109
+ ...
110
+
111
+ class SimplePublisher:
112
+ """
113
+ Publisher for sending uProtocol messages.
114
+
115
+ SimplePublisher provides an easy-to-use interface for publishing messages
116
+ to specific resources in the uProtocol network.
117
+ """
118
+
119
+ def __init__(self, transport: 'local_transport.LocalTransport', uri_provider: StaticUriProvider) -> None:
120
+ """
121
+ Create a new SimplePublisher.
122
+
123
+ Args:
124
+ transport: The transport to use for sending messages.
125
+ uri_provider: The URI provider for the publishing entity.
126
+
127
+ Raises:
128
+ Exception: If the runtime creation fails.
129
+
130
+ Example:
131
+ >>> from up_py_rs.communication import SimplePublisher
132
+ >>> from up_py_rs.local_transport import LocalTransport
133
+ >>> from up_py_rs import StaticUriProvider
134
+ >>> transport = LocalTransport()
135
+ >>> provider = StaticUriProvider("device", 0x1234, 0x01)
136
+ >>> publisher = SimplePublisher(transport, provider)
137
+ """
138
+ ...
139
+
140
+ def publish(self, resource_id: int, payload: Optional['communication.UPayload']) -> None:
141
+ """
142
+ Publish a message to a specific resource.
143
+
144
+ Args:
145
+ resource_id: The target resource ID (0 to 65535).
146
+ payload: The message payload, or None for empty messages.
147
+
148
+ Raises:
149
+ Exception: If publishing fails.
150
+
151
+ Example:
152
+ >>> from up_py_rs.communication import UPayload
153
+ >>> payload = UPayload.from_string("Hello")
154
+ >>> publisher.publish(0xb4c1, payload)
155
+ >>> # Or publish without payload:
156
+ >>> publisher.publish(0xb4c1, None)
157
+ """
158
+ ...
159
+
160
+
161
+ # Submodule: local_transport
162
+
163
+ class local_transport:
164
+ """Local transport module for in-process communication."""
165
+
166
+ class LocalTransport:
167
+ """
168
+ Provides local (in-process) transport for uProtocol communication.
169
+
170
+ LocalTransport enables communication between components within the same
171
+ process without network overhead. It manages listener registration and
172
+ message routing.
173
+ """
174
+
175
+ def __init__(self) -> None:
176
+ """
177
+ Create a new LocalTransport instance.
178
+
179
+ Raises:
180
+ Exception: If the runtime creation fails.
181
+
182
+ Example:
183
+ >>> from up_py_rs.local_transport import LocalTransport
184
+ >>> transport = LocalTransport()
185
+ """
186
+ ...
187
+
188
+ def register_listener(
189
+ self,
190
+ uri_provider: StaticUriProvider,
191
+ resource_id: int,
192
+ callback: Callable[[UMessage], None]
193
+ ) -> None:
194
+ """
195
+ Register a listener callback for a specific resource.
196
+
197
+ Args:
198
+ uri_provider: The URI provider identifying the entity.
199
+ resource_id: The resource ID to listen to (0 to 65535).
200
+ callback: A Python function that accepts a UMessage parameter.
201
+ Will be called when messages arrive.
202
+
203
+ Raises:
204
+ Exception: If registration fails.
205
+
206
+ Example:
207
+ >>> from up_py_rs import UMessage
208
+ >>> def my_handler(msg: UMessage):
209
+ ... print(msg.extract_string())
210
+ >>> transport.register_listener(uri_provider, 0xb4c1, my_handler)
211
+ """
212
+ ...
213
+
214
+ def unregister_listener(
215
+ self,
216
+ uri_provider: StaticUriProvider,
217
+ resource_id: int,
218
+ callback: Callable[[UMessage], None]
219
+ ) -> None:
220
+ """
221
+ Unregister a previously registered listener.
222
+
223
+ Args:
224
+ uri_provider: The URI provider used during registration.
225
+ resource_id: The resource ID to stop listening to.
226
+ callback: The same Python function that was registered.
227
+
228
+ Raises:
229
+ Exception: If unregistration fails or listener not found.
230
+
231
+ Note:
232
+ Currently may fail due to listener instance comparison issues.
233
+ Consider letting listeners be cleaned up automatically.
234
+ """
235
+ ...
236
+
237
+
238
+ __all__ = [
239
+ 'UMessage',
240
+ 'StaticUriProvider',
241
+ 'communication',
242
+ 'local_transport',
243
+ ]
up_py_rs/py.typed ADDED
File without changes
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: up-py-rs
3
+ Version: 0.0.4
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Requires-Python: >=3.8
@@ -0,0 +1,7 @@
1
+ up_py_rs-0.0.4.dist-info/METADATA,sha256=pSaNr9Bk73I6IhZXPNcNWpYeZehL4nXuD1VkGo7GsZc,257
2
+ up_py_rs-0.0.4.dist-info/WHEEL,sha256=UvGAAbe03xUOU6C6yq_72CCBHPkcyGWXJ1rPcGp8w-E,157
3
+ up_py_rs/__init__.py,sha256=p5P6YCGjkJ4AvlZXVnQuacBUjzsVzjccv3tN9o8sRGM,115
4
+ up_py_rs/__init__.pyi,sha256=Kzu6fp_eEfq9xrrv_TZhtLZhJy4HJ6SWQhdx1L2mqYE,8025
5
+ up_py_rs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ up_py_rs/up_py_rs.pypy310-pp73-x86-linux-gnu.so,sha256=fZ7fA8rM3tzfjRrNCs3WbSyUvMjNC17Zy_7PoWqtCCE,4369092
7
+ up_py_rs-0.0.4.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.10.2)
3
+ Root-Is-Purelib: false
4
+ Tag: pp310-pypy310_pp73-manylinux_2_17_i686
5
+ Tag: pp310-pypy310_pp73-manylinux2014_i686