Weave documentation
Rust referenceweave-woven

weave-woven · crate

Source declarations, signatures and documentation for crate.

Reviewed implementation boundary: Use open when persisted dedup hydration is needed; in-process broadcast does not prove remote acceptance or durable replication. See /libraries/woven/overview.

Source: sigil/weave/models/woven/src/lib.rs. SHA-256: 4fcca901177f16555a7cb3a455bc25d3fc5272b59e585a3aa760242348bcc3cb.

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.

::Result

Result type for WOVEN protocol operations.

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

Source line: 18.

::WovenError

Errors returned by WOVEN protocol operations.

#[derive(Debug, Error, PartialEq, Eq)]
pub enum WovenError {
    /// A typed identifier is empty or uses the wrong scheme.
    #[error("invalid {kind}: {value}")]
    InvalidIdentifier {
        /// Identifier kind.
        kind: &'static str,
        /// Rejected value.
        value: String,
    },

    /// An event kind is empty or malformed.
    #[error("invalid event kind: {0}")]
    InvalidKind(String),

    /// A JSON value could not be encoded canonically.
    #[error("canonical encoding failed: {0}")]
    CanonicalEncoding(String),

    /// A strand record is not a WOVEN event envelope.
    #[error("invalid strand record: {0}")]
    InvalidStrandRecord(String),

    /// A Strand operation failed.
    #[error("strand operation failed: {0}")]
    Strand(String),

    /// A Nexus operation failed.
    #[error("nexus operation failed: {0}")]
    Nexus(String),

    /// A transport operation failed.
    #[error("transport operation failed: {0}")]
    Transport(String),

    /// A stored event failed signature verification.
    #[error("event signature verification failed at strand sequence {seq}")]
    VerificationFailed {
        /// Strand sequence containing the rejected event.
        seq: u64,
    },

    /// A typed application schema could not parse an event.
    #[error("schema error: {0}")]
    Schema(String),
}

Source line: 22.

::SpaceId

A WOVEN app space, such as woven://dsocial/global.

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct SpaceId(String);

Source line: 71.

::SpaceId::new

Parse and validate a WOVEN space identifier.

pub fn new(value: impl Into<String>) -> Result<Self>;

Source line: 75.

::SpaceId::as_str

Return the identifier as a string slice.

pub fn as_str(&self) -> &str;

Source line: 88.

::EventRef

A reference to a WOVEN event or object.

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct EventRef(String);

Source line: 96.

::EventRef::new

Parse and validate a WOVEN reference.

pub fn new(value: impl Into<String>) -> Result<Self>;

Source line: 100.

::EventRef::as_str

Return the reference as a string slice.

pub fn as_str(&self) -> &str;

Source line: 113.

::Event

A signed WOVEN event.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Event {

}

Source line: 120.

::EventRecord

A WOVEN event with its Strand sequence.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EventRecord {
/// Strand sequence number.

pub seq: u64,
/// Verified event.

pub event: Event
}

Source line: 136.

::AggregatedEventRecord

A verified event from a Nexus-merged multi-writer feed.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AggregatedEventRecord {
/// Source writer key from the Nexus view.

pub source_writer: String,
/// Sequence number in the source Strand.

pub seq: u64,
/// Verified event.

pub event: Event
}

Source line: 145.

::NexusEventFeed

Nexus-backed WOVEN feed over many single-writer strands.

pub struct NexusEventFeed {

}

Source line: 155.

::WovenTransport

WOVEN transport helpers over weave-swarm.

pub struct WovenTransport;

Source line: 160.

::WovenTransport::topic_for_space

Derive the swarm discovery topic for a WOVEN space.

pub fn topic_for_space(space: &SpaceId) -> weave_swarm::TopicId;

Source line: 164.

::WovenTransport::encode_event

Encode an event as a WOVEN transport payload.

pub fn encode_event(event: &Event) -> Result<Vec<u8>>;

Source line: 169.

::WovenTransport::decode_event

Decode and verify a WOVEN transport payload.

pub fn decode_event(bytes: &[u8]) -> Result<Event>;

Source line: 180.

::WovenTransport::join_space

Join the swarm topic for a WOVEN space.

pub async fn join_space(swarm: &weave_swarm::Swarm, space: &SpaceId) -> Result<()>;

Source line: 207.

::WovenTransport::broadcast_event

Broadcast a WOVEN event to currently connected swarm peers.

pub async fn broadcast_event(swarm: &weave_swarm::Swarm, event: &Event) -> Result<usize>;

Source line: 218.

::WovenTransportService

Stateful receiver for WOVEN payloads delivered by weave-swarm.

The service verifies incoming transport envelopes, rejects events for spaces it did not join, deduplicates by deterministic event ID, and persists accepted events into a Strand.

pub struct WovenTransportService {

}

Source line: 232.

::WovenTransportService::new

Create a transport service over a shared local Strand.

Dedup state starts empty. Prefer [Self::open] when reopening an existing durable Strand so already-persisted event IDs are hydrated.

pub fn new(
        spaces: impl IntoIterator<Item = SpaceId>,
        strand: Arc<Mutex<strand::Strand>>,
    ) -> Self;

Source line: 243.

::WovenTransportService::open

Open a transport service and hydrate dedup state from the Strand.

Ensures a fresh process does not re-accept events already persisted on the backing Strand.

pub async fn open(
        spaces: impl IntoIterator<Item = SpaceId>,
        strand: Arc<Mutex<strand::Strand>>,
    ) -> Result<Self>;

Source line: 258.

::WovenTransportService::strand

Return the shared Strand used by this service.

pub fn strand(&self) -> &Arc<Mutex<strand::Strand>>;

Source line: 280.

::WovenTransportService::spaces

Return the joined WOVEN spaces accepted by this receiver.

pub fn spaces(&self) -> &BTreeSet<SpaceId>;

Source line: 285.

::WovenTransportService::join_spaces

Join every configured WOVEN space on the provided swarm.

pub async fn join_spaces(&self, swarm: &weave_swarm::Swarm) -> Result<()>;

Source line: 290.

::WovenTransportService::handle_payload

Decode, verify, deduplicate, and persist one transport payload.

Returns Ok(None) when the event was already accepted earlier.

pub async fn handle_payload(&self, payload: &[u8]) -> Result<Option<EventRecord>>;

Source line: 300.

::WovenTransportService::handle_swarm_event

Handle a single swarm event if it carries WOVEN application data.

pub async fn handle_swarm_event(
        &self,
        event: weave_swarm::SwarmEvent,
    ) -> Result<Option<EventRecord>>;

Source line: 322.

::WovenTransportService::query

Query verified local events from the service Strand.

pub async fn query(&self, filter: &EventFilter) -> Result<Vec<EventRecord>>;

Source line: 343.

::NexusEventFeed::new

Create a new WOVEN feed.

pub async fn new(viewing_node: impl Into<String>) -> Result<Self>;

Source line: 391.

::NexusEventFeed::add_strand

Add a single-writer Strand to the feed.

pub async fn add_strand(&self, strand: Arc<strand::Strand>) -> Result<()>;

Source line: 403.

::NexusEventFeed::query

Generate a verified, filtered multi-writer feed.

pub async fn query(&self, filter: &EventFilter) -> Result<Vec<AggregatedEventRecord>>;

Source line: 411.

::EventStream

Strand-backed storage adapter for WOVEN events.

pub struct EventStream;

Source line: 444.

::EventStream::append

Append a signed WOVEN event to a Strand.

pub async fn append(strand: &mut strand::Strand, event: &Event) -> Result<EventRecord>;

Source line: 448.

::EventStream::read_all

Read and verify every WOVEN event in a Strand.

pub async fn read_all(strand: &strand::Strand) -> Result<Vec<EventRecord>>;

Source line: 461.

::EventStream::query

Read, verify, and filter WOVEN events from a Strand.

pub async fn query(strand: &strand::Strand, filter: &EventFilter) -> Result<Vec<EventRecord>>;

Source line: 476.

::Event::id

Return this event's deterministic ID.

pub fn id(&self) -> &EventRef;

Source line: 487.

::Event::author

Return the author DID or identity URI.

pub fn author(&self) -> &str;

Source line: 492.

::Event::space

Return this event's app space.

pub fn space(&self) -> &SpaceId;

Source line: 497.

::Event::kind

Return the event kind, such as social.post.

pub fn kind(&self) -> &str;

Source line: 502.

::Event::refs

Return referenced events/objects.

pub fn refs(&self) -> &[EventRef];

Source line: 507.

::Event::attachments

Return attachment references, usually Locus refs.

pub fn attachments(&self) -> &[String];

Source line: 512.

::Event::capabilities

Return capability references attached to this event.

pub fn capabilities(&self) -> &[String];

Source line: 517.

::Event::body

Return the JSON body.

pub fn body(&self) -> &Value;

Source line: 522.

::Event::created_at

Return the creation timestamp in seconds.

pub fn created_at(&self) -> u64;

Source line: 527.

::Event::public_key

Return the signer public key.

pub fn public_key(&self) -> &[u8; 32];

Source line: 532.

::Event::verify

Verify the deterministic event ID and Ed25519 signature.

pub fn verify(&self, public_key: &[u8; 32]) -> Result<bool>;

Source line: 537.

::Event::to_strand_bytes

Encode this event for storage in a Strand block.

pub fn to_strand_bytes(&self) -> Result<Vec<u8>>;

Source line: 556.

::Event::from_strand_bytes

Decode a WOVEN event from a Strand block payload.

pub fn from_strand_bytes(bytes: &[u8]) -> Result<Self>;

Source line: 566.

::EventBuilder

Builder for signed WOVEN events.

#[derive(Debug, Clone)]
pub struct EventBuilder {

}

Source line: 621.

::EventBuilder::new

Create a new event builder.

pub fn new(author: impl Into<String>, space: SpaceId, kind: impl Into<String>) -> Self;

Source line: 634.

::EventBuilder::body

Set the JSON body.

pub fn body(mut self, body: Value) -> Self;

Source line: 648.

::EventBuilder::created_at

Set the creation timestamp in seconds.

pub fn created_at(mut self, created_at: u64) -> Self;

Source line: 654.

::EventBuilder::ref_event

Add an event/object reference.

pub fn ref_event(mut self, event_ref: EventRef) -> Self;

Source line: 660.

::EventBuilder::attachment

Add an attachment reference, typically a Locus URL/ref.

pub fn attachment(mut self, attachment: impl Into<String>) -> Self;

Source line: 666.

::EventBuilder::capability

Add a capability reference.

pub fn capability(mut self, capability: impl Into<String>) -> Self;

Source line: 672.

::EventBuilder::sign

Sign and build the event.

pub fn sign(self, keypair: &weave_crypto::KeyPair) -> Result<Event>;

Source line: 678.

::EventBuilder::sign_with

Sign and build the event with an external signing adapter.

pub fn sign_with<F>(self, public_key: [u8; 32], signer: F) -> Result<Event>
    where
        F: FnOnce(&[u8]) -> Result<Vec<u8>>,;

Source line: 685.

::EventFilter

Query filter for event streams and local indexes.

#[derive(Debug, Clone, Default)]
pub struct EventFilter {

}

Source line: 726.

::EventFilter::new

Create an empty filter. Empty fields are wildcards.

pub fn new() -> Self;

Source line: 737.

::EventFilter::space

Match a space.

pub fn space(mut self, space: SpaceId) -> Self;

Source line: 742.

::EventFilter::kind

Match an event kind.

pub fn kind(mut self, kind: impl Into<String>) -> Self;

Source line: 748.

::EventFilter::author

Match an author.

pub fn author(mut self, author: impl Into<String>) -> Self;

Source line: 754.

::EventFilter::references

Match an event/object reference.

pub fn references(mut self, reference: EventRef) -> Self;

Source line: 760.

::EventFilter::since

Match events at or after this timestamp.

pub fn since(mut self, timestamp: u64) -> Self;

Source line: 766.

::EventFilter::until

Match events at or before this timestamp.

pub fn until(mut self, timestamp: u64) -> Self;

Source line: 772.

::EventFilter::matches

Return true when the event satisfies every populated filter field.

pub fn matches(&self, event: &Event) -> bool;

Source line: 778.

dsocial

dSocial typed event schemas over WOVEN.

pub mod dsocial;

Source line: 887.

dsocial::Profile

dSocial profile event body.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Profile {
/// Display name shown in clients.

pub display_name: String,
/// Optional profile bio.

pub bio: Option<String>,
/// Optional avatar Locus reference.

pub avatar: Option<String>
}

Source line: 894.

dsocial::Profile::KIND

WOVEN event kind for profile updates.

pub const KIND: &'static str;

Source line: 905.

dsocial::Profile::new

Create a profile body.

pub fn new(display_name: impl Into<String>) -> Self;

Source line: 908.

dsocial::Profile::bio

Set profile bio.

pub fn bio(mut self, bio: impl Into<String>) -> Self;

Source line: 917.

dsocial::Profile::avatar

Set avatar reference.

pub fn avatar(mut self, avatar: impl Into<String>) -> Self;

Source line: 923.

dsocial::Profile::sign

Sign as a WOVEN event.

pub fn sign(
            &self,
            author: impl Into<String>,
            space: SpaceId,
            created_at: u64,
            keypair: &weave_crypto::KeyPair,
        ) -> Result<Event>;

Source line: 929.

dsocial::Profile::parse

Parse from a WOVEN event.

pub fn parse(event: &Event) -> Result<Self>;

Source line: 940.

dsocial::Post

dSocial post event body.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Post {
/// Post text.

pub text: String,
/// Attachment Locus references.

pub attachments: Vec<String>
}

Source line: 947.

dsocial::Post::KIND

WOVEN event kind for posts.

pub const KIND: &'static str;

Source line: 956.

dsocial::Post::new

Create a post body.

pub fn new(text: impl Into<String>) -> Self;

Source line: 959.

dsocial::Post::attachment

Add an attachment reference.

pub fn attachment(mut self, attachment: impl Into<String>) -> Self;

Source line: 967.

dsocial::Post::sign

Sign as a WOVEN event.

pub fn sign(
            &self,
            author: impl Into<String>,
            space: SpaceId,
            created_at: u64,
            keypair: &weave_crypto::KeyPair,
        ) -> Result<Event>;

Source line: 973.

dsocial::Post::parse

Parse from a WOVEN event.

pub fn parse(event: &Event) -> Result<Self>;

Source line: 990.

dsocial::Reply

dSocial reply event body.

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Reply {
/// Parent post/reply reference.

pub parent: EventRef,
/// Reply text.

pub text: String
}

Source line: 997.

dsocial::Reply::KIND

WOVEN event kind for replies.

pub const KIND: &'static str;

Source line: 1006.

dsocial::Reply::new

Create a reply.

pub fn new(parent: EventRef, text: impl Into<String>) -> Self;

Source line: 1009.

dsocial::Reply::sign

Sign as a WOVEN event.

pub fn sign(
            &self,
            author: impl Into<String>,
            space: SpaceId,
            created_at: u64,
            keypair: &weave_crypto::KeyPair,
        ) -> Result<Event>;

Source line: 1017.

dsocial::Reply::parse

Parse from a WOVEN event.

pub fn parse(event: &Event) -> Result<Self>;

Source line: 1032.

dsocial::Follow

dSocial follow event body.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Follow {
/// Target DID being followed.

pub target: String
}

Source line: 1046.

dsocial::Follow::KIND

WOVEN event kind for follows.

pub const KIND: &'static str;

Source line: 1053.

dsocial::Follow::new

Create a follow body.

pub fn new(target: impl Into<String>) -> Self;

Source line: 1056.

dsocial::Follow::sign

Sign as a WOVEN event.

pub fn sign(
            &self,
            author: impl Into<String>,
            space: SpaceId,
            created_at: u64,
            keypair: &weave_crypto::KeyPair,
        ) -> Result<Event>;

Source line: 1063.

dsocial::Follow::parse

Parse from a WOVEN event.

pub fn parse(event: &Event) -> Result<Self>;

Source line: 1074.

dsocial::Reaction

dSocial reaction event body.

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Reaction {
/// Target event reference.

pub target: EventRef,
/// Reaction value, for example `+`.

pub reaction: String
}

Source line: 1081.

dsocial::Reaction::KIND

WOVEN event kind for reactions.

pub const KIND: &'static str;

Source line: 1090.

dsocial::Reaction::new

Create a reaction.

pub fn new(target: EventRef, reaction: impl Into<String>) -> Self;

Source line: 1093.

dsocial::Reaction::sign

Sign as a WOVEN event.

pub fn sign(
            &self,
            author: impl Into<String>,
            space: SpaceId,
            created_at: u64,
            keypair: &weave_crypto::KeyPair,
        ) -> Result<Event>;

Source line: 1101.

dsocial::Reaction::parse

Parse from a WOVEN event.

pub fn parse(event: &Event) -> Result<Self>;

Source line: 1116.

On this page

::Result::WovenError::SpaceId::SpaceId::new::SpaceId::as_str::EventRef::EventRef::new::EventRef::as_str::Event::EventRecord::AggregatedEventRecord::NexusEventFeed::WovenTransport::WovenTransport::topic_for_space::WovenTransport::encode_event::WovenTransport::decode_event::WovenTransport::join_space::WovenTransport::broadcast_event::WovenTransportService::WovenTransportService::new::WovenTransportService::open::WovenTransportService::strand::WovenTransportService::spaces::WovenTransportService::join_spaces::WovenTransportService::handle_payload::WovenTransportService::handle_swarm_event::WovenTransportService::query::NexusEventFeed::new::NexusEventFeed::add_strand::NexusEventFeed::query::EventStream::EventStream::append::EventStream::read_all::EventStream::query::Event::id::Event::author::Event::space::Event::kind::Event::refs::Event::attachments::Event::capabilities::Event::body::Event::created_at::Event::public_key::Event::verify::Event::to_strand_bytes::Event::from_strand_bytes::EventBuilder::EventBuilder::new::EventBuilder::body::EventBuilder::created_at::EventBuilder::ref_event::EventBuilder::attachment::EventBuilder::capability::EventBuilder::sign::EventBuilder::sign_with::EventFilter::EventFilter::new::EventFilter::space::EventFilter::kind::EventFilter::author::EventFilter::references::EventFilter::since::EventFilter::until::EventFilter::matchesdsocialdsocial::Profiledsocial::Profile::KINDdsocial::Profile::newdsocial::Profile::biodsocial::Profile::avatardsocial::Profile::signdsocial::Profile::parsedsocial::Postdsocial::Post::KINDdsocial::Post::newdsocial::Post::attachmentdsocial::Post::signdsocial::Post::parsedsocial::Replydsocial::Reply::KINDdsocial::Reply::newdsocial::Reply::signdsocial::Reply::parsedsocial::Followdsocial::Follow::KINDdsocial::Follow::newdsocial::Follow::signdsocial::Follow::parsedsocial::Reactiondsocial::Reaction::KINDdsocial::Reaction::newdsocial::Reaction::signdsocial::Reaction::parse