pub struct ThreadContext {
pub events: Vec<EventReference>,
pub mentioned_pubkeys: Vec<PublicKey>,
}Expand description
NIP-10 thread metadata for a kind: 1 note.
Fields§
§events: Vec<EventReference>Every e tag, in the order they appear on the wire.
mentioned_pubkeys: Vec<PublicKey>Pubkeys collected from the p tags.
Implementations§
Source§impl ThreadContext
impl ThreadContext
Sourcepub fn reference(self, reference: EventReference) -> Self
pub fn reference(self, reference: EventReference) -> Self
Append an event reference and return self.
Sourcepub fn root(&self) -> Option<&EventReference>
pub fn root(&self) -> Option<&EventReference>
First reference whose marker is NoteMarker::Root, if any.
Sourcepub fn reply(&self) -> Option<&EventReference>
pub fn reply(&self) -> Option<&EventReference>
First reference whose marker is NoteMarker::Reply, if any.
Sourcepub fn mentions(&self) -> impl Iterator<Item = &EventReference>
pub fn mentions(&self) -> impl Iterator<Item = &EventReference>
Every reference whose marker is NoteMarker::Mention.
Sourcepub fn infer_legacy_markers(self) -> Self
pub fn infer_legacy_markers(self) -> Self
Fill in markers on e references that came from the deprecated
positional form of NIP-10.
Per NIP-10 §“deprecated positional form”: when an event carries
e tags without explicit markers, the position determines the
role:
- 0 unmarked references: nothing to do
- 1 unmarked reference: it is the
NoteMarker::Root - 2+ unmarked references: first is
NoteMarker::Root, last isNoteMarker::Reply, every entry in between isNoteMarker::Mention
Existing markers are never overwritten — references that already
have a marker keep it. This makes the operation safe to call on
any ThreadContext, including ones produced by
ThreadContext::from_event on a legacy thread mixed with
modern markers.
Render the context as the Tags that go into a kind: 1 note.
Sourcepub fn from_event(event: &Event) -> Self
pub fn from_event(event: &Event) -> Self
Reconstruct a ThreadContext from event’s tags.
The parser is tolerant: malformed e/p tags are skipped instead
of failing the whole event, since real-world clients have produced
many variations over the years. Use EventReference::from_tag
directly for the strict, fail-fast version.
Trait Implementations§
Source§impl Clone for ThreadContext
impl Clone for ThreadContext
Source§fn clone(&self) -> ThreadContext
fn clone(&self) -> ThreadContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ThreadContext
impl Debug for ThreadContext
Source§impl Default for ThreadContext
impl Default for ThreadContext
Source§fn default() -> ThreadContext
fn default() -> ThreadContext
impl Eq for ThreadContext
Source§impl PartialEq for ThreadContext
impl PartialEq for ThreadContext
impl StructuralPartialEq for ThreadContext
Auto Trait Implementations§
impl Freeze for ThreadContext
impl RefUnwindSafe for ThreadContext
impl Send for ThreadContext
impl Sync for ThreadContext
impl Unpin for ThreadContext
impl UnsafeUnpin for ThreadContext
impl UnwindSafe for ThreadContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.