pub struct CompactReaction {
pub id: [u8; 32],
pub emoji_idx: u32,
pub author_idx: u16,
}Expand description
Memory-efficient reaction: binary id, interned author, interned (emoji, url) pair.
40 bytes and Copy, so adding or removing one never allocates per reaction.
Fields§
§id: [u8; 32]Reaction event ID as binary
emoji_idx: u32The (emoji, NIP-30 url) pair, interned via NpubInterner::intern_emoji
Author npub index (interned via NpubInterner)
Implementations§
Source§impl CompactReaction
impl CompactReaction
Sourcepub fn emoji<'a>(&self, interner: &'a NpubInterner) -> &'a str
pub fn emoji<'a>(&self, interner: &'a NpubInterner) -> &'a str
The emoji, resolved through the interner it was interned with.
Sourcepub fn from_reaction(reaction: &Reaction, interner: &mut NpubInterner) -> Self
pub fn from_reaction(reaction: &Reaction, interner: &mut NpubInterner) -> Self
Convert from regular Reaction, interning author and emoji
Sourcepub fn from_reaction_owned(
reaction: Reaction,
interner: &mut NpubInterner,
) -> Self
pub fn from_reaction_owned( reaction: Reaction, interner: &mut NpubInterner, ) -> Self
Convert from regular Reaction (owned), interning author and emoji
Sourcepub fn to_reaction(&self, parent_hex: &str, interner: &NpubInterner) -> Reaction
pub fn to_reaction(&self, parent_hex: &str, interner: &NpubInterner) -> Reaction
Convert back to regular Reaction, resolving author from interner.
parent_hex is the reacted-to message’s id: a CompactReaction is always nested
inside that message, so its id IS the reference.
Trait Implementations§
Source§impl Clone for CompactReaction
impl Clone for CompactReaction
impl Copy for CompactReaction
Source§impl Debug for CompactReaction
impl Debug for CompactReaction
impl Eq for CompactReaction
Source§impl PartialEq for CompactReaction
impl PartialEq for CompactReaction
impl StructuralPartialEq for CompactReaction
Auto Trait Implementations§
impl Forget for CompactReaction
impl Freeze for CompactReaction
impl Move for CompactReaction
impl RefUnwindSafe for CompactReaction
impl Send for CompactReaction
impl Sync for CompactReaction
impl Unpin for CompactReaction
impl UnsafeUnpin for CompactReaction
impl UnwindSafe for CompactReaction
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
Mutably borrows from an owned value. Read more
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more