pub struct PyMessageBusScope { /* private fields */ }Expand description
Owns a component’s Python subscriptions without owning the runtime bus.
Implementations§
Source§impl PyMessageBusScope
impl PyMessageBusScope
Sourcepub fn publish_message(&self, topic: &str, message: Py<PyAny>) -> PyResult<()>
pub fn publish_message(&self, topic: &str, message: Py<PyAny>) -> PyResult<()>
Publishes the original Python object synchronously on an application topic.
Handlers receive the same object. Nested publication finishes before the outer call returns. Python handler exceptions are logged and do not interrupt other handlers. This does not serialize or externally publish the object.
§Errors
Returns an error if the topic is invalid or the registered runtime bus is no longer active.
Sourcepub fn subscribe_topic(
&self,
py: Python<'_>,
topic: &str,
handler: Py<PyAny>,
priority: u32,
) -> PyResult<()>
pub fn subscribe_topic( &self, py: Python<'_>, topic: &str, handler: Py<PyAny>, priority: u32, ) -> PyResult<()>
Subscribes a callable to an application topic pattern.
Higher priorities run first. Repeating a pattern and callable within this component is a no-op, even with a different priority. Unsubscribe first to change priority. Python-defined bound methods are identified by their receiver and function; other callables use object identity. Subscriptions owned by other components remain independent.
§Errors
Returns an error for an invalid pattern, a non-callable handler, or an inactive runtime bus.
Sourcepub fn unsubscribe_topic(
&self,
topic: &str,
handler: &Bound<'_, PyAny>,
) -> PyResult<()>
pub fn unsubscribe_topic( &self, topic: &str, handler: &Bound<'_, PyAny>, ) -> PyResult<()>
Removes this component’s exact topic pattern and callable subscription.
An absent subscription is a no-op. A callback already snapshotted by a synchronous publication may still run in that publication.
§Errors
Returns an error for an invalid pattern, a non-callable handler, or an inactive runtime bus.