Search documentation of macula

# macula_net_transport behaviour (macula v4.4.9)

View Source

Transport 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

1. Caller starts the transport's listener (impl-specific args).
2. Caller registers an inbound handler via the `set_handler/1` callback; the transport calls this for every CBOR envelope it receives.
3. Caller establishes outbound links via the impl's `connect` function (impl-specific).
4. The `send/2` callback delivers an encoded envelope to a known station.

# Summary

## Types

cbor_envelope/0
handler/0
station_id/0
stream_ref/0

## Callbacks

send/2
set_handler/1

# Types

# cbor_envelope/0

    -type cbor_envelope() :: binary().

# handler/0

    -type handler() :: fun((cbor_envelope(), stream_ref()) -> any()).

# station_id/0

    -type station_id() :: binary().

# stream_ref/0

    -type stream_ref() :: reference().

# Callbacks

# send/2

    -callback send(station_id(), cbor_envelope()) -> ok | {error, term()}.

# set_handler/1

    -callback set_handler(handler()) -> ok.