Weave documentation
Forum

Pattern Match

Forum matches full byte equality; richer queries require separate application state.

Pattern(pub Vec<u8>) matches only when the entire tuple equals the pattern bytes. There are no wildcards, prefixes, field predicates or blocking subscriptions. read returns one matching value without consuming it; take removes one matching map entry.

To use structured payloads, keep their serialization stable and retain the full bytes used for an exact match. Prefixing a kind field does not add prefix matching to this API. Forum exposes no enumeration/query method or public accessor that lets an external helper mutate its private live index.

The following is a sequential local example on a fresh instance:

use std::sync::Arc;
use tokio::sync::RwLock;
use strand::{Strand, StrandConfig};
use forum::{Forum, Pattern};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let dir = tempfile::tempdir()?;
    let cfg = StrandConfig::default().with_storage(dir.path());
    let strand = Arc::new(RwLock::new(Strand::new(cfg).await?));
    let forum = Forum::new(strand);

    forum.write(b"ping".to_vec()).await?;

    // read does not consume — call it twice, get the same tuple twice.
    let a = forum.read(&Pattern(b"ping".to_vec())).await?;
    let b = forum.read(&Pattern(b"ping".to_vec())).await?;
    assert_eq!(a, b);
    assert_eq!(a.as_deref(), Some(b"ping".as_slice()));

    Ok(())
}

Source declarations