Skip to main content

Crate peat_ffi

Crate peat_ffi 

Source
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§

CellInfo
Peat Cell information for display
CommandInfo
Command information for C2
DocumentChange
Document change event for subscriptions
MarkerInfo
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).
NodeConfig
Configuration for creating a PeatNode
NodeInfo
Node information for display
PeatNode
A Peat network node with P2P sync capabilities
PeerInfo
Information about a peer node for connection
PeerTransportState
Per-peer transport state across all registered transports.
Position
Geographic position for FFI
SubscriptionHandle
Handle for an active document subscription
SyncStats
Sync statistics
TrackData
Track data for CoT encoding
TrackInfo
Track information for display
TransportConfigFFI
Transport configuration for BLE and other transports (ADR-039, #556)
TransportLink
One transport’s link state for a peer (FFI mirror of peat_mesh::transport::LinkState).
UniFfiTraitVtableDocumentCallback
Velocity
Velocity vector for FFI

Enums§

CellStatus
Cell status enumeration
ChangeType
Type of document change event
CommandStatus
Command status enumeration
NodeStatus
Node status enumeration
PeatError
FFI Error type
TrackCategory
Track category enumeration
TransportLinkQuality
Bucketed link quality for UI tier indicators.
TransportPathKind
Connection path classification.

Traits§

DocumentCallback
Callback interface for document change notifications

Functions§

JNI_OnLoad
JNI_OnLoad - Called when library is loaded via System.loadLibrary()
Java_com_defenseunicorns_peat_PeatJni_blobAddPeerJni
JNI: Add a known blob peer.
Java_com_defenseunicorns_peat_PeatJni_blobEndpointIdJni
JNI: Get blob endpoint ID as hex string (or null if blob transfer disabled).
Java_com_defenseunicorns_peat_PeatJni_blobExistsLocallyJni
JNI: Check if blob exists locally.
Java_com_defenseunicorns_peat_PeatJni_blobGetJni
JNI: Fetch blob bytes by hash. Returns byte[] or null.
Java_com_defenseunicorns_peat_PeatJni_blobPutJni
JNI: Store bytes as a blob. Returns the content hash as a hex string.
Java_com_defenseunicorns_peat_PeatJni_clearGlobalNodeHandleJni
JNI: Release the owning reference stored in [GLOBAL_NODE_HANDLE].
Java_com_defenseunicorns_peat_PeatJni_connectPeerJni
Connect to a known peer by node ID and address (bypasses mDNS).
Java_com_defenseunicorns_peat_PeatJni_connectedPeersJni
JNI: Get connected peer IDs as a JSON array
Java_com_defenseunicorns_peat_PeatJni_createNodeJni
JNI: Create a Peat node (simplified for testing)
Java_com_defenseunicorns_peat_PeatJni_createNodeWithConfigJni
JNI: Create a PeatNode with transport configuration (ADR-039, #558)
Java_com_defenseunicorns_peat_PeatJni_enableBlobTransferJni
JNI: Enable blob transfer on the PeatNode.
Java_com_defenseunicorns_peat_PeatJni_endpointSocketAddrJni
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 what connectPeerJni expects as its address argument when one in-process instance dials another on loopback (no discovery layer to populate it). peat-mesh#138 M4.
Java_com_defenseunicorns_peat_PeatJni_forceStoreErrorForTestingJni
JNI: Test-only fault injection. Arms a one-shot flag so the next getDocumentJni call short-circuits to the Err branch (throws RuntimeException) without touching the underlying store. Self- clears on consumption.
Java_com_defenseunicorns_peat_PeatJni_freeNodeJni
JNI: Free a PeatNode handle
Java_com_defenseunicorns_peat_PeatJni_getCellsJni
JNI: Get all cells as JSON array string
Java_com_defenseunicorns_peat_PeatJni_getCommandsJni
JNI: Get all commands as JSON array string
Java_com_defenseunicorns_peat_PeatJni_getDocumentJni
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_PeatJni_getGlobalNodeHandleJni
JNI: Get the global node handle (survives APK replacement)
Java_com_defenseunicorns_peat_PeatJni_getMarkersJni
JNI: Get all markers as JSON array string
Java_com_defenseunicorns_peat_PeatJni_getNodesJni
JNI: Get all nodes as JSON array string
Java_com_defenseunicorns_peat_PeatJni_getTracksJni
JNI: Get all tracks as JSON array string
Java_com_defenseunicorns_peat_PeatJni_nativeInit
Register native methods for PeatJni class
Java_com_defenseunicorns_peat_PeatJni_nodeIdJni
JNI: Get node ID from a PeatNode handle
Java_com_defenseunicorns_peat_PeatJni_peatVersion
JNI: Get Peat library version
Java_com_defenseunicorns_peat_PeatJni_peerCountJni
JNI: Get peer count from a PeatNode handle
Java_com_defenseunicorns_peat_PeatJni_publishDocumentJni
Publish a generic document into a named collection via peat_mesh::Node.
Java_com_defenseunicorns_peat_PeatJni_publishDocumentWithOriginJni
Origin-aware sibling of [Java_..._publishDocumentJni] (ADR-059 Amendment 2 — Slice 1.b.4 host-side wiring).
Java_com_defenseunicorns_peat_PeatJni_publishMarkerJni
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_PeatJni_publishNodeJni
JNI: Publish a node (self-position/PLI) to the Peat network
Java_com_defenseunicorns_peat_PeatJni_requestSyncJni
JNI: Request full document sync with all connected peers
Java_com_defenseunicorns_peat_PeatJni_startSyncJni
JNI: Start sync on a PeatNode
Java_com_defenseunicorns_peat_PeatJni_subscribeDocumentChangesJni
JNI: Subscribe to document change notifications
Java_com_defenseunicorns_peat_PeatJni_testJni
JNI: Test that JNI bindings work
Java_com_defenseunicorns_peat_PeatJni_unsubscribeDocumentChangesJni
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