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.
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.rsBasisStore— libs/weave-sdk/src/node.rsConnectedPeer— libs/weave-sdk/src/network_manager.rsDriveAcl— libs/weave-sdk/src/visibility.rsDriveInfo— libs/weave-sdk/src/drive_manager.rsDriveManager— libs/weave-sdk/src/drive_manager.rsForumStore— libs/weave-sdk/src/node.rsGnosisStore— libs/weave-sdk/src/node.rsLensStore— libs/weave-sdk/src/node.rsLocusStore— libs/weave-sdk/src/node.rsMessagingManager— libs/weave-sdk/src/messaging.rsNetworkConfig— 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(())
}