WeaveDocs
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.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::{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(())
}