WeaveDocs
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.rs
  • HelloMessage — filament-minimal/src/packet.rs
  • Identity — filament-minimal/src/crypto.rs
  • LocalInterface — filament-minimal/src/interface.rs
  • MessageRouter — filament-minimal/src/interface.rs
  • Packet — filament-minimal/src/packet.rs
  • PacketHeader — filament-minimal/src/packet.rs
  • PendingSession — filament-minimal/src/crypto.rs
  • ReceivedMessage — filament-minimal/src/interface.rs
  • CryptoError — filament-minimal/src/crypto.rs
  • InterfaceError — filament-minimal/src/interface.rs
  • PacketError — 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(())
}