macula_net_transport behaviour (macula v3.15.1)
View SourceTransport plugin contract for macula-net.
Per the macula-net spec (PLAN_MACULA_NET.md §7.1), the macula-net core operates on abstract links — bidirectional, reliable- delivery, framed channels with station identity. Each transport (QUIC, BATMAN-adv, LoRa, satellite, ...) implements this behaviour to be pluggable.
Lifecycle
- Caller starts the transport's listener (impl-specific args).
- Caller registers an inbound handler via
set_handler/1; the transport calls this for every CBOR envelope it receives. - Caller establishes outbound links via the impl's
connectfunction (impl-specific). send/2delivers an encoded envelope to a known station.
Summary
Types
-type cbor_envelope() :: binary().
-type handler() :: fun((cbor_envelope(), stream_ref()) -> any()).
-type station_id() :: binary().
-type stream_ref() :: reference().
Callbacks
-callback send(station_id(), cbor_envelope()) -> ok | {error, term()}.
-callback set_handler(handler()) -> ok.