Skip to main content

ThreadedMessageStore

Struct ThreadedMessageStore 

Source
pub struct ThreadedMessageStore { /* private fields */ }
Expand description

Per-thread append-only message store with G-Set CRDT semantics (REQ-300).

Uses HashIndex for O(1) lookup (REQ-309) and deduplication (REQ-310). Maintains a frontier set per thread for efficient leaf queries.

Implementations§

Source§

impl ThreadedMessageStore

Source

pub fn new() -> Self

Creates an empty message store.

Source

pub fn append_envelope( &mut self, envelope: RedactedEnvelope, signer: &dyn Signer, ) -> Result<bool, AttestError>

Accept a redacted envelope (SPEC-015 REQ-702).

Verifies the envelope’s R4 v2 attestation from its own fields first (signer embodies verification for the envelope’s sender key), then places it in the thread its authenticated thread field names — there is deliberately no thread parameter, so cross-thread injection of a genuine envelope is a signature failure at the source, not a policy question. An unverifiable envelope is never stored.

Returns Ok(true) if newly shelved, Ok(false) if an envelope for this content hash is already present (G-Set dedup, as for messages).

Source

pub fn append_opened( &mut self, envelope: OpenedEnvelope, signer: &dyn Signer, ) -> Result<bool, OpenedError>

Accept an opened envelope (SPEC-017 REQ-813).

Verifies the v3 root-signature and every field-opening from the envelope’s own fields first (signer embodies verification for the sender key), then shelves it under its typed root, placed in the thread its authenticated Thread opening names. As with Self::append_envelope there is deliberately no thread parameter, so cross-thread injection of a genuine envelope is a signature/opening failure at the source, not a policy question; an envelope that does not open its Thread leaf cannot be placed (fail closed).

Returns Ok(true) if newly shelved, Ok(false) if an opened envelope for this root is already present (G-Set dedup).

Trait Implementations§

Source§

impl Clone for ThreadedMessageStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ThreadedMessageStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ThreadedMessageStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl MessageStore for ThreadedMessageStore

Source§

fn lookup(&self, hash: &ContentHash) -> Option<&Message>

Look up a message by content hash across all threads.
Source§

fn lookup_in_thread( &self, hash: &ContentHash, thread: &ThreadId, ) -> Option<&Message>

Look up a message by content hash within a specific thread (ADR-008).
Source§

fn contains(&self, hash: &ContentHash, thread: &ThreadId) -> bool

Check whether a content hash exists in the given thread.
Source§

fn append( &mut self, hash: ContentHash, thread: ThreadId, message: Message, ) -> bool

Append a message to a thread. Returns false if the hash already exists (deduplication per REQ-310). Returns true if newly inserted.
Source§

fn frontier(&self, thread: &ThreadId) -> Vec<&ContentHash>

Returns the frontier (leaf messages) of a thread — messages not referenced by any other message’s :caused-by in the same thread.
Source§

fn causal_closure( &self, hash: &ContentHash, thread: &ThreadId, ) -> Vec<ContentHash>

Returns the causal closure (principal ideal) of a message — all messages reachable by transitively following :caused-by links back to root(s).
Source§

fn envelope_in_thread( &self, hash: &ContentHash, thread: &ThreadId, ) -> Option<&RedactedEnvelope>

Look up a redacted envelope by the content hash of the message it redacts, scoped to the envelope’s authenticated thread (SPEC-015 REQ-702). Read more
Source§

fn opened_in_thread( &self, hash: &ContentHash, thread: &ThreadId, ) -> Option<&OpenedEnvelope>

Look up an opened envelope by the typed content root of the message it opens, scoped to the envelope’s authenticated Thread opening (SPEC-017 REQ-813). Read more
Source§

fn materialized_positions(&self) -> Option<&MaterializedPositions>

Optional independently admitted or snapshot-attested native position cache. Implementations must bind installation to the same code/root/thread. The resolver checks that binding again; default None preserves legacy behavior.

Auto Trait Implementations§

§

impl Forget for ThreadedMessageStore

§

impl Freeze for ThreadedMessageStore

§

impl Move for ThreadedMessageStore

§

impl RefUnwindSafe for ThreadedMessageStore

§

impl Send for ThreadedMessageStore
where RawTable<(ThreadId, Vec<(ContentHash, Message)>)>: Send, RawTable<(ContentHash, (ThreadId, usize))>: Send, RawTable<(ThreadId, HashSet<ContentHash>)>: Send, RawTable<(ContentHash, RedactedEnvelope)>: Send, RawTable<(ContentHash, OpenedEnvelope)>: Send,

§

impl Sync for ThreadedMessageStore
where RawTable<(ThreadId, Vec<(ContentHash, Message)>)>: Sync, RawTable<(ContentHash, (ThreadId, usize))>: Sync, RawTable<(ThreadId, HashSet<ContentHash>)>: Sync, RawTable<(ContentHash, RedactedEnvelope)>: Sync, RawTable<(ContentHash, OpenedEnvelope)>: Sync,

§

impl Unpin for ThreadedMessageStore
where *const u8 is !null: Unpin, *const LeafNode<String, SetValZST> is !null: Unpin, Box<(String, SetValZST)>: Unpin, Box<Message>: Unpin, *const LeafNode<KeyId, SetValZST> is !null: Unpin, Box<(KeyId, SetValZST)>: Unpin,

§

impl UnsafeUnpin for ThreadedMessageStore

§

impl UnwindSafe for ThreadedMessageStore
where NonNull<u8>: UnwindSafe, RawVecInner: UnwindSafe, BTreeMap<String, SetValZST>: UnwindSafe, BoxRaw<Message>: UnwindSafe, BTreeMap<KeyId, SetValZST>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.