WeaveDocs
Weave Sdk

Node Builder

Node builder for the Weave SDK — declarative configuration for storage, network, identity, and replication adapters.

Purpose

Application SDK for identities, drives, stores, messaging, replication, and peer networking.

This page follows the real source shape for Weave Sdk 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.

Tip

A WeaveNode is the single object an application talks to. Production apps should construct one node at startup and pass it through the application — do not construct primitives (Strand::new, Locus::new, etc.) directly.

Primary types to know

  • AgentMessage — libs/weave-sdk/src/messaging.rs
  • BasisStore — libs/weave-sdk/src/node.rs
  • ConnectedPeer — libs/weave-sdk/src/network_manager.rs
  • DriveAcl — libs/weave-sdk/src/visibility.rs
  • DriveInfo — libs/weave-sdk/src/drive_manager.rs
  • DriveManager — libs/weave-sdk/src/drive_manager.rs
  • ForumStore — libs/weave-sdk/src/node.rs
  • GnosisStore — libs/weave-sdk/src/node.rs
  • LensStore — libs/weave-sdk/src/node.rs
  • LocusStore — libs/weave-sdk/src/node.rs
  • MessagingManager — libs/weave-sdk/src/messaging.rs
  • NetworkConfig — libs/weave-sdk/src/network_manager.rs

Example shape

use weave_sdk::prelude::*;

#[tokio::main]
async fn main() -> WeaveResult<()> {
    // WeaveNode::builder() returns a WeaveNodeBuilder. Required fields are
    // namespace + identifier (used to derive the OAS DID) and a storage_dir.
    // Optional builder methods set bootstrap peers, listening port, and
    // identity overrides.
    let node = WeaveNode::builder()
        .namespace("l1fe")
        .identifier("example-agent")
        .storage_dir("/tmp/weave-example")
        .bootstrap(&["/ip4/203.0.113.10/udp/4040/quic"])
        .port(0)
        .mdns(true)
        .build()
        .await?;

    // The constructed node exposes its DID and config; the namespace/identifier
    // pair is hashed into the discovery key reused by strands and the swarm.
    println!(
        "did={} dht_port={} storage={}",
        node.identity().did(),
        node.config().dht_port,
        node.config().storage_dir.display(),
    );
    Ok(())
}