Weave documentation

Store and read notes

A local Locus workflow, with explicit boundaries for sharing.

Prerequisites

Use an authorized local Weave source checkout. Add weave-sdk as a path dependency to libs/weave-sdk; its manifest version is 1.1.0. This avoids assuming a public registry artifact. The snippets use the current SDK methods in libs/weave-sdk/src/node.rs.

[dependencies]
weave-sdk = { path = "../weave/libs/weave-sdk" }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

Adjust the path from your application's Cargo.toml. Use an application-owned local data directory. The sample opens local stores and does not start networking.

Write one note and read it back

Locus provides filesystem operations over signed storage. This first example has one writer and one local drive.

use weave_sdk::prelude::*;

#[tokio::main]
async fn main() -> WeaveResult<()> {
    let node = WeaveNode::builder()
        .namespace("docs-example")
        .identifier("notes")
        .storage_dir("./data/notes")
        .build()
        .await?;
    node.open_locus("notes").await?;
    node.locus_write_file("notes", "/hello.txt", b"Hello, Weave.").await?;
    let bytes = node.locus_read_file("notes", "/hello.txt").await?;
    assert_eq!(bytes, b"Hello, Weave.");
    println!("{}", String::from_utf8_lossy(&bytes));
    Ok(())
}

Share deliberately

Two nodes independently opening a drive with the same name do not establish a shared writer or automatically merge edits. A receiver must open the remote resource with its source public key, establish an authorized replication path and verify fetched blocks. See replication and the node API.

Handle failures

Propagate write/read errors. Keep the data directory across process restarts. Test restart recovery and remote access separately; this single-process example does not certify concurrent collaboration or crash recovery under every failure mode.

On this page