Expand description
A transport the host implements: callbacks that cross the C boundary.
Everything else in this crate drives a transport pamoja wrote. This module goes the other way: the host supplies the functions that connect, send, subscribe, and receive, and pamoja wraps them in a transport that composes like any other, as a ladder rung, under a fault injector, or driven directly. It is how a link pamoja does not ship, a vendor SDK, a proprietary radio, a cloud client, or a class in a language binding, takes its place on a node.
§The contract
A host fills a PamojaTransportCallbacks and hands it, with a user_data
pointer, to pamoja_transport_from_callbacks. Every callback receives that
pointer back. The callbacks are ordinary blocking functions:
connect,send, andsubscribeare called one at a time per transport, from a thread pamoja owns, never the caller’s thread. Each returnsPamojaStatus::Okor a status describing the failure; a host that wants the failure explained sets the text withpamoja_last_error_seton the same thread before returning.recvis optional. A link that only sends, an uplink, leaves it null and is never listened on. When present it is called repeatedly from one background thread, from the momentconnectsucceeds, each call as soon as the previous returned. It blocks until a message is available, builds the message withpamoja_message_new, stores it inout_message, and returnsPamojaStatus::Ok; it stores null and returnsPamojaStatus::Okonce the link has ended and no further messages will arrive, which stops the calls. A failure status stops them too, and the next receive through pamoja reports that failure, with the text set bypamoja_last_error_set. The nextconnectstarts the calls again. Because it runs on its own thread, it may overlap with the other three callbacks.releaseis optional. It is called once, after the transport is dropped and after every callback still running has returned, so it may free whateveruser_datapoints at.
Messages the host delivers are queued inside the transport, so a receive
through pamoja is cancel-safe whatever the host’s recv does.
Structs§
- Callback
Transport - A transport whose every operation is a host callback.
- Pamoja
Transport Callbacks - The functions a host supplies to stand as a transport.
Functions§
- pamoja_
last_ ⚠error_ set - Records the text a host callback wants attached to the status it returns.
- pamoja_
message_ ⚠new - Builds a message for a host’s
recvcallback to deliver. - pamoja_
transport_ ⚠from_ callbacks - Wraps host callbacks in a transport.