Expand description
Peat FFI - Foreign Function Interface for Kotlin/Swift
This crate provides UniFFI bindings to expose Peat functionality to Kotlin (Android) and Swift (iOS) consumer applications.
§Features
- CoT Encoding: Convert track data to Cursor-on-Target XML
- Sync (optional): P2P document sync via AutomergeIroh backend
Uses proc-macro only UniFFI approach (no UDL file).
§Android JNI Support
This crate also provides direct JNI bindings that bypass JNA’s symbol lookup issues on Android. The JNI functions are exported with standard naming (Java_package_Class_method) and can be called directly via Android’s NDK.
Modules§
- collections
- Well-known collection names for Peat data
- dart_
ffi
Structs§
- Cell
Info - Peat Cell information for display
- Command
Info - Command information for C2
- Document
Change - Document change event for subscriptions
- Marker
Info - Operator-placed map marker — the typed shape every peer renders in the Peat Markers panel and on the MapView (ADR-035 Universal Document transport, “markers” collection).
- Node
Config - Configuration for creating a PeatNode
- Node
Info - Node information for display
- Peat
Node - Wraps AutomergeIrohBackend for authenticated document sync. Requires matching app_id and shared_key for peer connections.
- Peer
Info - Information about a peer node for connection
- Peer
Transport State - Per-peer transport state across all registered transports.
- Position
- Geographic position for FFI
- Subscription
Handle - Handle for an active document subscription
- Sync
Stats - Sync statistics
- Track
Data - Track data for CoT encoding
- Track
Info - Track information for display
- Transport
ConfigFFI - Transport configuration for BLE and other transports (ADR-039, #556)
- Transport
Link - One transport’s link state for a peer (FFI mirror of
peat_mesh::transport::LinkState). - UniFfi
Trait Vtable Document Callback - Velocity
- Velocity vector for FFI
Enums§
- Cell
Status - Cell status enumeration
- Change
Origin - Where a document change came from — a local write vs. a remote peer’s sync.
- Change
Type - Type of document change event
- Command
Status - Command status enumeration
- Node
Status - Node status enumeration
- Peat
Error - FFI Error type
- Track
Category - Track category enumeration
- Transport
Link Quality - Bucketed link quality for UI tier indicators.
- Transport
Path Kind - Connection path classification.
Traits§
- Document
Callback - Callback interface for document change notifications
Functions§
- JNI_
OnLoad - JNI_OnLoad - Called when library is loaded via System.loadLibrary()
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ blob AddPeer Jni - JNI: Add a known blob peer.
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ blob Endpoint IdJni - JNI: Get blob endpoint ID as hex string (or null if blob transfer disabled).
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ blob Exists Locally Jni - JNI: Check if blob exists locally.
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ blob GetJni - JNI: Fetch blob bytes by hash. Returns byte[] or null.
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ blob PutJni - JNI: Store bytes as a blob. Returns the content hash as a hex string.
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ clear Global Node Handle Jni - JNI: Release the owning reference stored in [
GLOBAL_NODE_HANDLE]. - Java_
com_ defenseunicorns_ peat_ Peat Jni_ connect Peer Jni - Connect to a known peer by node ID and address (bypasses mDNS).
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ connected Peers Jni - JNI: Get connected peer IDs as a JSON array
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ create Node Jni - JNI: Create a Peat node (simplified for testing)
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ create Node With Config Jni - JNI: Create a PeatNode with transport configuration (ADR-039, #558)
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ enable Blob Transfer Jni - JNI: Enable blob transfer on the PeatNode.
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ endpoint Socket Addr Jni - JNI: Get this node’s iroh-endpoint first IP socket address as an
"ip:port"string, or null if no socket is bound. The result is whatconnectPeerJniexpects as itsaddressargument when one in-process instance dials another on loopback (no discovery layer to populate it). peat-mesh#138 M4. - Java_
com_ defenseunicorns_ peat_ Peat Jni_ force Store Error ForTesting Jni - JNI: Test-only fault injection. Arms a one-shot flag so the next
getDocumentJnicall short-circuits to the Err branch (throws RuntimeException) without touching the underlying store. Self- clears on consumption. - Java_
com_ defenseunicorns_ peat_ Peat Jni_ free Node Jni - JNI: Free a PeatNode handle
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ getCells Jni - JNI: Get all cells as JSON array string
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ getCommands Jni - JNI: Get all commands as JSON array string
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ getDocument Jni - JNI: Read a document back from the local store as JSON, or null
if the document doesn’t exist locally. Complements
publishDocumentJni— needed by instrumented tests that verify sync convergence by reading on the receiver side. peat-mesh#138 M4. - Java_
com_ defenseunicorns_ peat_ Peat Jni_ getGlobal Node Handle Jni - JNI: Get the global node handle (survives APK replacement)
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ getMarkers Jni - JNI: Get all markers as JSON array string
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ getNodes Jni - JNI: Get all nodes as JSON array string
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ getTracks Jni - JNI: Get all tracks as JSON array string
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ native Init - Register native methods for PeatJni class
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ node IdJni - JNI: Get node ID from a PeatNode handle
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ peat Version - JNI: Get Peat library version
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ peer Count Jni - JNI: Get peer count from a PeatNode handle
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ publish Document Jni - Publish a generic document into a named collection via
peat_mesh::Node. - Java_
com_ defenseunicorns_ peat_ Peat Jni_ publish Document With Origin Jni - Origin-aware sibling of [
Java_..._publishDocumentJni] (ADR-059 Amendment 2 — Slice 1.b.4 host-side wiring). - Java_
com_ defenseunicorns_ peat_ Peat Jni_ publish Marker Jni - JNI: Publish a marker into the doc store. Routes through the universal-Document transport on every registered radio (LiteBridgeTranslator on BLE, iroh sync for cross-mesh peers).
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ publish Node Jni - JNI: Publish a node (self-position/PLI) to the Peat network
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ request Sync Jni - JNI: Request full document sync with all connected peers
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ start Sync Jni - JNI: Start sync on a PeatNode
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ subscribe Document Changes Jni - JNI: Subscribe to document change notifications
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ test Jni - JNI: Test that JNI bindings work
- Java_
com_ defenseunicorns_ peat_ Peat Jni_ unsubscribe Document Changes Jni - JNI: Unsubscribe from document change notifications
- create_
node - Create a new PeatNode with FormationKey authentication
- create_
position - Create a position from coordinates
- create_
velocity - Create a velocity from bearing and speed
- encode_
track_ to_ cot - Encode a track to CoT XML string
- peat_
version - Get the Peat library version
- uniffi_
peat_ ffi_ fn_ init_ callback_ vtable_ documentcallback