Index a local feed
Append signed records to a Strand and maintain a Lens index.
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 the record before its index
This example uses Strand and Lens. It does not publish WOVEN events or create peer subscriptions. The record is UTF-8 JSON; the Lens key is borrowed as the SDK requires.
use weave_sdk::prelude::*;
#[tokio::main]
async fn main() -> WeaveResult<()> {
let node = WeaveNode::builder()
.namespace("docs-example")
.identifier("feed")
.storage_dir("./data/feed")
.build()
.await?;
node.create_strand("posts").await?;
node.open_lens("feed-index").await?;
let post = br#"{"body":"Hello, Weave","tag":"intro"}"#;
let sequence = node.append("posts", post).await?;
let key = format!("sequence/{sequence:020}");
node.lens_put("feed-index", key.as_bytes(), post).await?;
let indexed = node.lens_get("feed-index", key.as_bytes()).await?;
assert_eq!(indexed.as_deref(), Some(post.as_slice()));
println!("Indexed sequence {sequence}");
Ok(())
}Rebuild and extend
Appending to Strand and writing Lens are distinct operations. A failure between them leaves a record without its derived index. Track a replay position and rebuild entries from the source Strand before exposing a complete feed. Opening an existing resource and handling duplicate names is an application lifecycle decision.
For signed topic events use WOVEN and its actual transport interface. For peer replication use the replication guide; a local Lens is not a globally synchronized feed.