[][src]Struct tbot::state::messages::Messages

pub struct Messages<S> { /* fields omitted */ }

A storage of state per message. See the module's docs to learn how to use it.

Implementations

impl<S> Messages<S>[src]

#[must_use]pub fn new() -> Self[src]

Constructs a new message storage.

#[must_use]pub fn with_capacity(capacity: usize) -> Self[src]

Constructs a new message storage with capacity for n messages.

pub fn all_messages(&self) -> impl Iterator<Item = MessageId> + '_[src]

Returns an iterator over the stored messages.

pub fn messages_in_chat_by_id(
    &self,
    chat_id: Id
) -> impl Iterator<Item = Id> + '_
[src]

Returns an iterator over stored message IDs for a chat by its ID.

pub fn messages_in_chat<C>(&self, context: &C) -> impl Iterator<Item = Id> + '_ where
    C: Message
[src]

Returns an iterator over stored message IDs for a chat, which ID is inferred from the context.

pub fn all_states(&self) -> impl Iterator<Item = &S>[src]

Returns an iterator over the stored states.

pub fn states_in_chat_by_id(&self, chat_id: Id) -> impl Iterator<Item = &S>[src]

Returns an iterator over stored states for messages in a chat by its ID.

pub fn states_in_chat<C>(&self, context: &C) -> impl Iterator<Item = &S> where
    C: Message
[src]

Returns an iterator over stored states for messages in a chat, which ID is inferred from the context.

pub fn iter(&self) -> impl Iterator<Item = (MessageId, &S)>[src]

Returns an iterator over stored messages and their states.

pub fn iter_in_chat_by_id(&self, chat_id: Id) -> impl Iterator<Item = (Id, &S)>[src]

Returns an iterator over stored messages and their states in a chat by its ID.

pub fn iter_in_chat<C>(&self, context: &C) -> impl Iterator<Item = (Id, &S)> where
    C: Message
[src]

Returns an iterator over stored messages and their states in a chat, which ID is inferred from the context.

pub fn iter_mut(&mut self) -> impl Iterator<Item = (MessageId, &mut S)>[src]

Returns a mutable iterator over the stored messages and their states.

pub fn iter_mut_in_chat_by_id(
    &mut self,
    chat_id: Id
) -> impl Iterator<Item = (Id, &mut S)>
[src]

Returns a mutable iterator over the stored messages and their states in a chat by its ID.

pub fn iter_mut_in_chat<C>(
    &mut self,
    context: &C
) -> impl Iterator<Item = (Id, &mut S)> where
    C: Message
[src]

Returns a mutable iterator over the stored messages and their states in a chat, which ID is inferred from the context.

pub fn into_iter_in_chat_by_id(
    self,
    chat_id: Id
) -> impl Iterator<Item = (Id, S)>
[src]

Returns an owning iterator over the stored messages and their states in a chat by its ID.

pub fn into_iter_in_chat<C>(self, context: &C) -> impl Iterator<Item = (Id, S)> where
    C: Message
[src]

Returns an owning iterator over the stored messages and their states in a chat, which ID is inferred from the context.

#[must_use]pub fn len(&self) -> usize[src]

Returns how many messages are stored.

#[must_use]pub fn len_in_chat_by_id(&self, chat_id: Id) -> usize[src]

Returns how many messages from a chat are stored.

#[must_use]pub fn len_in_chat<C>(&self, context: &C) -> usize where
    C: Message
[src]

Returns how many messages from a chat, which ID is inferred from the context, are stored.

#[must_use]pub fn capacity(&self) -> usize[src]

Returns the storage's capacity.

#[must_use]pub fn is_empty(&self) -> bool[src]

Returns true if the store is empty.

#[must_use]pub fn is_empty_in_chat_by_id(&self, chat_id: Id) -> bool[src]

Returns if the store does not have messages from a chat.

#[must_use]pub fn is_empty_in_chat<C>(&self, context: &C) -> bool where
    C: Message
[src]

Returns if the store does not have messages from a chat, inferring its ID from the context.

#[must_use = "use `clear` if you don't need the iterator"]pub fn drain(&mut self) -> impl Iterator<Item = (MessageId, S)> + '_[src]

Clears the storage, returning each stored item in an iterator.

pub fn clear(&mut self)[src]

Clears the store.

pub fn clear_in_chat_by_id(&mut self, chat_id: Id)[src]

Deletes state for all messages from a chat.

pub fn clear_in_chat<C>(&mut self, context: &C) where
    C: Message
[src]

Deletes state for all messages from a chat, inferring its ID from the context.

pub fn reserve(&mut self, additional: usize)[src]

Reserves capacity for n additional messages.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity to already stored messages.

#[must_use]pub fn get_by_id(&self, id: MessageId) -> Option<&S>[src]

Gets a message's state by its ID.

#[must_use]pub fn get<C>(&self, context: &C) -> Option<&S> where
    C: Message
[src]

Gets a message's state, inferring its ID from the context.

#[must_use]pub fn get_mut_by_id(&mut self, id: MessageId) -> Option<&mut S>[src]

Gets a mutable reference to a message's state by its ID.

#[must_use]pub fn get_mut<C>(&mut self, context: &C) -> Option<&mut S> where
    C: Message
[src]

Gets a mutable reference to a message's state, inferring its ID from the context.

#[must_use]pub fn entry_by_id(&mut self, id: MessageId) -> Entry<MessageId, S>[src]

Gets an entry to a message's state by its ID.

#[must_use]pub fn entry<C>(&mut self, context: &C) -> Entry<MessageId, S> where
    C: Message
[src]

Gets an entry to a message's state, inferring its ID from the context.

#[must_use]pub fn has_by_id(&self, id: MessageId) -> bool[src]

Checks if there's state for a message by its ID.

#[must_use]pub fn has<C>(&self, context: &C) -> bool where
    C: Message
[src]

Checks if there's state for a message, inferring its ID from the context.

pub fn insert_by_id(&mut self, id: MessageId, value: S) -> Option<S>[src]

Inserts state for a message by its ID. Returns the previous state.

pub fn insert<C>(&mut self, context: &C, value: S) -> Option<S> where
    C: Message
[src]

Inserts state for a message, inferring its ID from the context. Returns the previous state.

pub fn remove_by_id(&mut self, id: MessageId) -> Option<S>[src]

Removes and returns a message's state by its ID.

pub fn remove<C>(&mut self, context: &C) -> Option<S> where
    C: Message
[src]

Removes and returns a message's state, inferring its ID from the context.

pub fn retain<P>(&mut self, predicate: P) where
    P: FnMut(MessageId, &mut S) -> bool
[src]

Calls the predicate for each stored entry and deletes entries for which the predicate returns false.

Trait Implementations

impl<S: Clone> Clone for Messages<S>[src]

impl<S: Debug> Debug for Messages<S>[src]

impl<S> Default for Messages<S>[src]

impl<'de, S> Deserialize<'de> for Messages<S> where
    S: Deserialize<'de>, 
[src]

impl<S: Eq> Eq for Messages<S>[src]

impl<'a, S: Copy> Extend<(MessageId, &'a S)> for Messages<S>[src]

impl<S> Extend<(MessageId, S)> for Messages<S>[src]

impl<S> FromIterator<(MessageId, S)> for Messages<S>[src]

impl<S> Index<MessageId> for Messages<S>[src]

type Output = S

The returned type after indexing.

impl<S> IntoIterator for Messages<S>[src]

type Item = (MessageId, S)

The type of the elements being iterated over.

type IntoIter = IntoIter<MessageId, S>

Which kind of iterator are we turning this into?

impl<'a, S> IntoIterator for &'a Messages<S>[src]

type Item = (MessageId, &'a S)

The type of the elements being iterated over.

type IntoIter = Iter<'a, S>

Which kind of iterator are we turning this into?

impl<'a, S> IntoIterator for &'a mut Messages<S>[src]

type Item = (MessageId, &'a mut S)

The type of the elements being iterated over.

type IntoIter = IterMut<'a, S>

Which kind of iterator are we turning this into?

impl<S: PartialEq> PartialEq<Messages<S>> for Messages<S>[src]

impl<S> Serialize for Messages<S> where
    S: Serialize
[src]

impl<S> StructuralEq for Messages<S>[src]

impl<S> StructuralPartialEq for Messages<S>[src]

Auto Trait Implementations

impl<S> RefUnwindSafe for Messages<S> where
    S: RefUnwindSafe

impl<S> Send for Messages<S> where
    S: Send

impl<S> Sync for Messages<S> where
    S: Sync

impl<S> Unpin for Messages<S> where
    S: Unpin

impl<S> UnwindSafe for Messages<S> where
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> WithSubscriber for T[src]