Filament Minimal
Internals
Internals of `filament-minimal` — minimal transport, link, and packet definitions sufficient for integration tests.
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::{HelloMessage, Identity, Packet, PacketType};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Lift the curtain on the wire format. Each Packet has a PacketHeader
// (sender, type, sequence, timestamp) plus a serialized payload that the
// verify() call validates against the sender's identity key.
let identity = Identity::generate();
let ephemeral = HelloMessage::new(*identity.public_key());
let packet = Packet::new(
*identity.public_key(),
PacketType::Hello,
0,
ephemeral.encode()?,
&identity,
)?;
packet.verify()?;
// encode/decode are deterministic; a re-encode round-trips bit-for-bit.
let bytes = packet.encode()?;
let parsed = Packet::decode(&bytes)?;
println!(
"sender={} type={:?} seq={} wire_bytes={}",
hex::encode(parsed.sender()),
parsed.packet_type(),
parsed.sequence(),
bytes.len(),
);
Ok(())
}