pub struct MessageLog { /* private fields */ }Expand description
The messages of one channel or conversation, ordered and bounded.
Implementations§
Source§impl MessageLog
impl MessageLog
Sourcepub fn with_retention(retention: usize) -> Self
pub fn with_retention(retention: usize) -> Self
An empty log holding at most this many messages.
Sourcepub fn insert(&mut self, message: ChatMessage) -> bool
pub fn insert(&mut self, message: ChatMessage) -> bool
Insert a message unless we already have it, returning whether it was new.
A message with an id is deduplicated by that id. One without is compared against the messages sharing its exact timestamp, which is enough to catch a replay while staying bounded: an unbounded content scan would be the only alternative.
Sourcepub fn get(&self, msgid: &str) -> Option<&ChatMessage>
pub fn get(&self, msgid: &str) -> Option<&ChatMessage>
Look one up by its network id.
Sourcepub fn get_mut(&mut self, msgid: &str) -> Option<&mut ChatMessage>
pub fn get_mut(&mut self, msgid: &str) -> Option<&mut ChatMessage>
Borrow one mutably by its network id, to attach a reaction or mark it redacted.
Sourcepub fn get_by_key(&self, key: &MessageKey) -> Option<&ChatMessage>
pub fn get_by_key(&self, key: &MessageKey) -> Option<&ChatMessage>
Look one up by where it sits in this log.
Change::MessageAdded reports a key rather than the message, so this is how a host turns
that notification into the message it names.
Sourcepub fn iter(&self) -> Values<'_, MessageKey, ChatMessage>
pub fn iter(&self) -> Values<'_, MessageKey, ChatMessage>
Every message, oldest first.
Sourcepub fn last(&self) -> Option<&ChatMessage>
pub fn last(&self) -> Option<&ChatMessage>
The most recent message.
Sourcepub fn first(&self) -> Option<&ChatMessage>
pub fn first(&self) -> Option<&ChatMessage>
The oldest message held, which is where a history request should resume from.
Trait Implementations§
Source§impl Clone for MessageLog
impl Clone for MessageLog
Source§fn clone(&self) -> MessageLog
fn clone(&self) -> MessageLog
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 MessageLog
impl Debug for MessageLog
Source§impl Default for MessageLog
impl Default for MessageLog
Source§impl<'de> Deserialize<'de> for MessageLog
impl<'de> Deserialize<'de> for MessageLog
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'a> IntoIterator for &'a MessageLog
impl<'a> IntoIterator for &'a MessageLog
Source§type Item = &'a ChatMessage
type Item = &'a ChatMessage
Source§type IntoIter = Values<'a, MessageKey, ChatMessage>
type IntoIter = Values<'a, MessageKey, ChatMessage>
Source§impl Serialize for MessageLog
impl Serialize for MessageLog
Source§impl TS for MessageLog
impl TS for MessageLog
Source§const DOCS: Option<&'static str>
const DOCS: Option<&'static str>
TS is derived, docs are
automatically read from your doc comments or #[doc = ".."] attributesSource§type WithoutGenerics = MessageLog
type WithoutGenerics = MessageLog
WithoutGenerics should just be Self.
If the type does have generic parameters, then all generic parameters must be replaced with
a dummy type, e.g ts_rs::Dummy or ().
The only requirement for these dummy types is that EXPORT_TO must be None. Read moreSource§fn decl_concrete() -> String
fn decl_concrete() -> String
TS::decl().
If this type is not generic, then this function is equivalent to TS::decl().Source§fn decl() -> String
fn decl() -> String
type User = { user_id: number, ... }.
This function will panic if the type has no declaration. Read moreSource§fn inline() -> String
fn inline() -> String
{ user_id: number }.
This function will panic if the type cannot be inlined.Source§fn inline_flattened() -> String
fn inline_flattened() -> String
This function will panic if the type cannot be flattened.
Source§fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn output_path() -> Option<&'static Path>
fn output_path() -> Option<&'static Path>
T should be exported.The returned path does not include the base directory from
TS_RS_EXPORT_DIR. Read moreSource§fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
§fn dependencies() -> Vec<Dependency>where
Self: 'static,
fn dependencies() -> Vec<Dependency>where
Self: 'static,
§fn export() -> Result<(), ExportError>where
Self: 'static,
fn export() -> Result<(), ExportError>where
Self: 'static,
TS::export_all]. Read more§fn export_all() -> Result<(), ExportError>where
Self: 'static,
fn export_all() -> Result<(), ExportError>where
Self: 'static,
To export only this type, without its dependencies, use [
TS::export]. Read more§fn export_all_to(out_dir: impl AsRef<Path>) -> Result<(), ExportError>where
Self: 'static,
fn export_all_to(out_dir: impl AsRef<Path>) -> Result<(), ExportError>where
Self: 'static,
To export only this type, without its dependencies, use [
TS::export]. Read more§fn export_to_string() -> Result<String, ExportError>where
Self: 'static,
fn export_to_string() -> Result<String, ExportError>where
Self: 'static,
§fn default_output_path() -> Option<PathBuf>
fn default_output_path() -> Option<PathBuf>
T should be exported. Read more