mirror of
https://github.com/ratspeak/rsLXMF
synced 2026-11-22 23:10:35 +00:00
122 lines
6.3 KiB
Markdown
122 lines
6.3 KiB
Markdown
# Rust API
|
|
|
|
This guide describes the 1.5.0 API, published as v1.5.0. Application code should use `lxmf_core::message_api`, which
|
|
re-exports the message types without wrappers. The equivalent module-qualified
|
|
paths remain available. The [1.5 migration guide](migrations/1.5.md) covers
|
|
the changes since 1.4.0.
|
|
|
|
The compiled `lxmf-core` `message` example demonstrates message construction,
|
|
signing, packing, and unpacking through this path.
|
|
|
|
## Stability
|
|
|
|
The 1.5 line follows LXMF 1.3.0. It makes stamp costs and values `f64`, keeps
|
|
the router's delivered ids, stamp costs, and tickets in LXMF's SQLite state
|
|
store, and marks the router and daemon configuration structs
|
|
`#[non_exhaustive]`. See the [1.5 migration guide](migrations/1.5.md).
|
|
|
|
`lxmf-core` is candidate stable, but that classification does not make every
|
|
public implementation detail a permanent API. The message facade is the
|
|
recommended application path. Router ownership, delivery orchestration,
|
|
propagation clients and nodes, handlers, persistence representations,
|
|
admission machinery, Link-delivery state, and raw Reticulum channels remain
|
|
provisional module-qualified APIs.
|
|
|
|
`lxmf-tools` supports the `lxmd-rs` binary and is not a public library
|
|
integration target.
|
|
|
|
Choosing the facade instead of the equivalent module-qualified path does not
|
|
change behavior. Upgrading from 1.3 to 1.4, and from 1.4 to 1.5, does change
|
|
message and persistence APIs; follow the migration guides. Further reductions
|
|
to the broader module tree require a reviewed API diff, downstream migration,
|
|
and an explicit version decision.
|
|
|
|
## Delivery-owner integration
|
|
|
|
`LinkDeliveryManager::poll_ready` lets one embedding task wait for inbound
|
|
delivery packets, local admission acknowledgements, endpoint lifecycle changes,
|
|
and staged-transport capacity. On readiness, call `drain_events` and `tick`.
|
|
Keep periodic ticks for protocol deadlines, but schedule application maintenance
|
|
separately. Drains are bounded and may leave another ready turn. Cancelling the
|
|
wait does not discard a packet or publish an unread endpoint binding; existing
|
|
periodic consumers remain supported. The API is provisional delivery-owner
|
|
integration, not a new wire protocol or success signal.
|
|
|
|
`LinkDeliveryManager::set_link_endpoint_dispatch_handle` opts Direct packet
|
|
sends into the Reticulum owner's exact local-admission receipts. Supply the
|
|
handle from the same runtime that owns the manager's transport channel.
|
|
Local FIFO residence and the subsequent measured-RTT proof wait are different
|
|
phases; neither is a recipient delivery confirmation.
|
|
|
|
Applications using responder-owned backchannels should forward the ordered
|
|
`LinkManagerAccountingEvent` packet and Resource wait observations through
|
|
`observe_backchannel_packet_wait` and `observe_backchannel_resource_wait`,
|
|
retaining the exact packet/resource identity and original timestamps.
|
|
Forward the optional exact packet-cancellation capability with its original
|
|
wait observation as well. A separate application owner can then cancel a
|
|
packet still awaiting local admission without closing the shared Link. This
|
|
cannot retract driver-admitted bytes. When a command receipt cannot be
|
|
published to its message owner, retain its exact identity for bounded cleanup;
|
|
close and drain a oneshot receiver before discarding it to fence concurrent
|
|
publication.
|
|
Adapters implementing that close-and-drain protocol can install their sender
|
|
with `set_cancellation_aware_backchannel_sender`, allowing cancellation before
|
|
the command receipt arrives to notify the adapter immediately. The existing
|
|
`set_backchannel_sender` retains legacy receipt-after-cancellation behavior.
|
|
Each pending send captures its adapter policy; replacing a sender does not
|
|
retroactively change cancellation semantics for older sends.
|
|
`message_timeout_window` exposes the finite current owner window for an outer
|
|
orphan watchdog. Externally observed Resource windows include a bounded
|
|
180-second notification allowance measured from the original protocol deadline;
|
|
this does not alter the Resource engine's timeout or delay explicit terminal
|
|
events. It is not renewed by receiving the same observation or by keepalives.
|
|
Queued messages without an active protocol owner receive no
|
|
blanket timeout exemption. Explicit rejection and cancellation are not evidence
|
|
of a failed route.
|
|
|
|
When an authenticated recipient announcement rules out compression, call
|
|
`LinkDeliveryManager::disable_pending_direct_compression` before advancing
|
|
ready delivery events. It updates unconstructed Direct Resources and queued
|
|
messages, including Link setup waits. Constructed Resources and split plans
|
|
remain immutable, and propagation envelopes keep their independent policy.
|
|
The call only disables compression; new submissions still carry their policy.
|
|
This additive API remains provisional delivery-owner integration.
|
|
|
|
Applications that reserve inbound attachment memory can opt into
|
|
`set_inbound_resource_completion_handler`. It receives one owned completed
|
|
payload before the ordinary conclusion callback, so an application can move
|
|
its exact Link/Resource reservation into a queued payload and retain it through
|
|
processing. This synchronous callback must not block. It replaces the legacy
|
|
inbound packet-channel delivery for that Resource, without cloning the data;
|
|
applications that do not install it keep the existing completion behavior.
|
|
|
|
## Compatibility checks
|
|
|
|
The `api/` directory contains the evidence used by CI:
|
|
|
|
- `stability.json` records package tiers, compatibility baselines, and snapshot
|
|
hashes;
|
|
- `snapshots/` records the explicit all-feature Apple ARM64 Rust API and the
|
|
manifest, feature, dependency, target, and MSRV contract; and
|
|
- `fixtures/` compiles recommended and retained imports as an external
|
|
consumer.
|
|
|
|
These checks catch accidental changes, but they do not replace platform builds,
|
|
wire and persistence tests, Python interoperability, or manual review. The API
|
|
snapshot omits auto-derived, auto-trait, and blanket implementations and is not
|
|
by itself a complete SemVer verdict.
|
|
|
|
Run the checks with:
|
|
|
|
```sh
|
|
python3 tools/check-api-baseline.py
|
|
python3 tools/check-api-manifest.py
|
|
python3 tools/check-api-compatibility.py
|
|
cargo check --manifest-path api/fixtures/Cargo.toml --locked
|
|
```
|
|
|
|
After reviewing an API change, run
|
|
`python3 tools/check-api-baseline.py --update` and commit the source and snapshot
|
|
changes together. CI compares snapshots with the current source; compatibility
|
|
checks retain the historical baseline.
|