Weave documentation
Rust referenceweave-forum

weave-forum · crate

Source declarations, signatures and documentation for crate.

Reviewed implementation boundary: Construction starts an empty tuple index without automatic log replay. take can remove local state before append fails, and its lock order differs from write. Read /libraries/forum/overview before assuming durable atomic coordination.

Source: sigil/weave/models/forum/src/lib.rs. SHA-256: 4ce7d4292883b6d3608a004c2d93310323a875c43b9eba8d2b83d56907b87ecd.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

::ForumError

Error types for Forum operations

#[derive(Debug, Error)]
pub enum ForumError {
    /// The underlying strand storage returned an error.
    #[error("Strand error: {0}")]
    Strand(String),
    /// The requested tuple could not be found.
    #[error("Tuple not found for pattern: {0:?}")]
    TupleNotFound(Pattern),
    /// Serialization or deserialization failed.
    #[error("Serialization error: {0}")]
    Serialization(#[from] serde_json::Error),
}

Source line: 22.

::Result

A result type for Forum operations.

pub type Result<T> = std::result::Result<T, ForumError>;

Source line: 35.

::EntryId

A unique identifier for an entry in the Forum's strand log.

pub type EntryId = u64;

Source line: 38.

::TupleEntry

Represents an entry in the Forum's strand log.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TupleEntry {
    /// A tuple that has been written to the space.
    Write {
        /// The unique ID of this write operation.
        id: EntryId,
        /// The tuple data.
        tuple: Vec<u8>,
    },
    /// A tombstone indicating that a tuple has been taken.
    Take {
        /// The ID of the `Write` entry that was taken.
        write_id: EntryId,
    },
}

Source line: 42.

::Pattern

A pattern used for matching tuples in read and take operations. For now, this is a simple wrapper around a byte vector, but can be extended to support more complex matching logic.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Pattern(pub Vec<u8>);

Source line: 61.

::Forum

The Forum, a decentralized tuple space.

pub struct Forum {

}

Source line: 64.

::Forum::new

Creates a new Forum.

Arguments

  • strand - The strand log to use for storage.
pub fn new(strand: Arc<RwLock<Strand>>) -> Self;

Source line: 77.

::Forum::write

Writes a tuple to the space.

This appends a TupleEntry::Write to the strand log and adds the tuple to the in-memory index.

pub async fn write(&self, tuple: Vec<u8>) -> Result<EntryId>;

Source line: 88.

::Forum::read

Reads a tuple from the space that matches the given pattern.

This operation does not consume the tuple.

pub async fn read(&self, pattern: &Pattern) -> Result<Option<Vec<u8>>>;

Source line: 112.

::Forum::take

Takes a tuple from the space that matches the given pattern.

This operation consumes the tuple, appending a TupleEntry::Take to the strand log and removing it from the in-memory index.

pub async fn take(&self, pattern: &Pattern) -> Result<Option<Vec<u8>>>;

Source line: 127.

On this page