Skip to main content

Chat

Struct Chat 

Source
pub struct Chat {
Show 15 fields pub id: String, pub chat_type: ChatType, pub participants: Vec<u16>, pub messages: CompactMessageVec, pub last_read: [u8; 32], pub created_at: u64, pub metadata: ChatMetadata, pub muted: bool, pub typing_participants: Vec<(u16, u64)>, pub wallpaper_path: String, pub wallpaper_ts: u64, pub wallpaper_blur: u8, pub wallpaper_dim: u8, pub wallpaper_url: String, pub wallpaper_uploader: String,
}

Fields§

§id: String§chat_type: ChatType§participants: Vec<u16>§messages: CompactMessageVec§last_read: [u8; 32]§created_at: u64§metadata: ChatMetadata§muted: bool§typing_participants: Vec<(u16, u64)>§wallpaper_path: String

Local cached file path for the per-DM wallpaper, or empty when unset. Populated from the most recent kind-30078 d=vector-wallpaper rumor received for this chat (the encrypted Blossom file is fetched and decrypted to this path).

§wallpaper_ts: u64

Rumor created_at (Unix seconds) that produced the current wallpaper. Used as the latest-write-wins tiebreaker on concurrent sets.

§wallpaper_blur: u8

Blur amount in pixels applied to the wallpaper background layer (0..=30, clamped on read). 0 means no blur.

§wallpaper_dim: u8

Brightness percent applied to the wallpaper background layer (0..=100, clamped on read). 100 means no darkening; 0 is fully dim. Default 70 keeps text readable on photographic wallpapers.

§wallpaper_url: String

Blossom URL of the encrypted wallpaper blob currently in effect. Used to DELETE the previous blob when we (or our other device) replace the wallpaper, so stale uploads don’t linger on servers.

§wallpaper_uploader: String

npub (bech32) of whichever account uploaded the current wallpaper. Gate on this before issuing the Blossom DELETE — only the original uploader’s signature satisfies the server’s auth challenge.

Implementations§

Source§

impl Chat

Source

pub fn new(id: String, chat_type: ChatType, participants: Vec<u16>) -> Self

Source

pub fn new_dm(their_npub: String, interner: &mut NpubInterner) -> Self

Source

pub fn new_community_channel( channel_id: String, participants: Vec<String>, interner: &mut NpubInterner, ) -> Self

A Community channel chat (GROUP_PROTOCOL.md). channel_id is the channel’s stable random id (hex); participants are the members known so far.

Source

pub fn message_count(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn last_message_time(&self) -> Option<u64>

Source

pub fn has_message(&self, id: &str) -> bool

Source

pub fn get_compact_message(&self, id: &str) -> Option<&CompactMessage>

Source

pub fn get_compact_message_mut( &mut self, id: &str, ) -> Option<&mut CompactMessage>

Source

pub fn get_message(&self, id: &str, interner: &NpubInterner) -> Option<Message>

Source

pub fn iter_compact(&self) -> Iter<'_, CompactMessage>

Source

pub fn get_all_messages(&self, interner: &NpubInterner) -> Vec<Message>

Source

pub fn get_last_messages( &self, n: usize, interner: &NpubInterner, ) -> Vec<Message>

Source

pub fn add_message( &mut self, message: Message, interner: &mut NpubInterner, ) -> bool

Source

pub fn add_compact_message(&mut self, message: CompactMessage) -> bool

Source

pub fn set_as_read(&mut self) -> bool

Source

pub fn internal_add_message( &mut self, message: Message, interner: &mut NpubInterner, ) -> bool

Source

pub fn get_message_mut(&mut self, id: &str) -> Option<&mut CompactMessage>

Source

pub fn to_serializable(&self, interner: &NpubInterner) -> SerializableChat

Source

pub fn to_serializable_with_last_n( &self, n: usize, interner: &NpubInterner, ) -> SerializableChat

Source

pub fn get_other_participant( &self, my_npub: &str, interner: &NpubInterner, ) -> Option<String>

Source

pub fn is_dm_with(&self, npub: &str, interner: &NpubInterner) -> bool

Source

pub fn is_community(&self) -> bool

Source

pub fn has_participant(&self, npub: &str, interner: &NpubInterner) -> bool

Source

pub fn get_active_typers(&self, interner: &NpubInterner) -> Vec<String>

Source

pub fn update_typing_participant(&mut self, handle: u16, expires_at: u64)

Source

pub fn id(&self) -> &String

Source

pub fn chat_type(&self) -> &ChatType

Source

pub fn participants(&self) -> &[u16]

Source

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

Source

pub fn created_at(&self) -> u64

Source

pub fn metadata(&self) -> &ChatMetadata

Source

pub fn muted(&self) -> bool

Trait Implementations§

Source§

impl Clone for Chat

Source§

fn clone(&self) -> Chat

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 Chat

Source§

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

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

impl DeepSize for Chat

Auto Trait Implementations§

§

impl Freeze for Chat

§

impl RefUnwindSafe for Chat

§

impl Send for Chat

§

impl Sync for Chat

§

impl Unpin for Chat

§

impl UnsafeUnpin for Chat

§

impl UnwindSafe for Chat

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more