Filament Minimal
Usage
Using `filament-minimal` for small runtime tests — minimal subset of Filament for integration surfaces.
Purpose
Minimal Filament package for small runtime tests and integration surfaces.
This page follows the real source shape for Filament Minimal and explains the workflow a developer is likely to use first.
Developer workflow
Start from the smallest constructor or builder, perform one meaningful operation, inspect the returned state, then add the relevant policy, storage, or network integration. The examples below should be expanded whenever the crate API changes.
Primary types to know
EncryptedSession— filament-minimal/src/crypto.rsHelloMessage— filament-minimal/src/packet.rsIdentity— filament-minimal/src/crypto.rsLocalInterface— filament-minimal/src/interface.rsMessageRouter— filament-minimal/src/interface.rsPacket— filament-minimal/src/packet.rsPacketHeader— filament-minimal/src/packet.rsPendingSession— filament-minimal/src/crypto.rsReceivedMessage— filament-minimal/src/interface.rsCryptoError— filament-minimal/src/crypto.rsInterfaceError— filament-minimal/src/interface.rsPacketError— filament-minimal/src/packet.rs
Example shape
use filament_minimal::{Identity, LocalInterface, MessageRouter};
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Build a node identity and the shared MessageRouter, then attach an
// interface. The router owns the in-memory mailbox; the interface drives
// sends and surfaces ReceivedMessages.
let identity = Identity::generate();
let router = MessageRouter::new();
let mut iface = LocalInterface::new(identity, Arc::clone(&router));
iface.start().await?;
iface.send(iface.node_id(), b"loopback".to_vec()).await?;
if let Some(msg) = iface.recv().await {
println!("got {} bytes from {}", msg.payload.len(), hex::encode(msg.from));
}
println!("node_id={}", hex::encode(iface.node_id()));
Ok(())
}