Messages and peer transport
Learn local tuple semantics before adding authenticated transport.
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, read and consume one tuple
Forum is a tuple space. This local exercise uses exact byte matching, then consumes the matched tuple. It does not claim end-to-end encrypted delivery to another process.
use weave_sdk::prelude::*;
#[tokio::main]
async fn main() -> WeaveResult<()> {
let node = WeaveNode::builder()
.namespace("docs-example")
.identifier("messages")
.storage_dir("./data/messages")
.build()
.await?;
node.open_forum("messages").await?;
let message = br#"{"to":"local-reader","body":"Hello"}"#.to_vec();
node.forum_write("messages", message.clone()).await?;
let read = node.forum_read("messages", &message).await?;
assert_eq!(read, Some(message.clone()));
let taken = node.forum_take("messages", &message).await?;
assert_eq!(taken, Some(message));
Ok(())
}Add the transport boundary
A production chat app needs authenticated peer identity, a verified recipient key, encrypted framing, authorized resource discovery, replay handling and delivery semantics. The secret stream, messaging API and replication interface describe those separate pieces. Do not infer remote encryption or delivery from a successful local Forum write.
Errors and delivery
A missing exact tuple returns None; it is not proof that a peer received or rejected a message. Keep application acknowledgments and retry identifiers separate from local tuple consumption.