[−][src]Struct tbot::state::messages::Messages
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]
&self,
chat_id: Id
) -> impl Iterator<Item = Id> + '_
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]
C: Message,
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]
C: Message,
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]
C: Message,
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]
&mut self,
chat_id: Id
) -> impl Iterator<Item = (Id, &mut S)>
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]
&mut self,
context: &C
) -> impl Iterator<Item = (Id, &mut S)> where
C: Message,
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]
self,
chat_id: Id
) -> impl Iterator<Item = (Id, S)>
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]
C: Message,
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]
C: Message,
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]
C: Message,
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]
C: Message,
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]
C: Message,
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]
C: Message,
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]
C: Message,
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]
C: Message,
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]
C: Message,
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]
C: Message,
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]
P: FnMut(MessageId, &mut S) -> bool,
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]
S: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<S: Eq> Eq for Messages<S>
[src]
impl<'a, S: Copy> Extend<(MessageId, &'a S)> for Messages<S>
[src]
fn extend<I: IntoIterator<Item = (MessageId, &'a S)>>(&mut self, iterator: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<S> Extend<(MessageId, S)> for Messages<S>
[src]
fn extend<I: IntoIterator<Item = (MessageId, S)>>(&mut self, iterator: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<S> FromIterator<(MessageId, S)> for Messages<S>
[src]
impl<S> Index<MessageId> for Messages<S>
[src]
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?
fn into_iter(self) -> Self::IntoIter
[src]
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?
fn into_iter(self) -> Self::IntoIter
[src]
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?
fn into_iter(self) -> Self::IntoIter
[src]
impl<S: PartialEq> PartialEq<Messages<S>> for Messages<S>
[src]
impl<S> Serialize for Messages<S> where
S: Serialize,
[src]
S: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
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,
S: RefUnwindSafe,
impl<S> Send for Messages<S> where
S: Send,
S: Send,
impl<S> Sync for Messages<S> where
S: Sync,
S: Sync,
impl<S> Unpin for Messages<S> where
S: Unpin,
S: Unpin,
impl<S> UnwindSafe for Messages<S> where
S: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> WithSubscriber for T
[src]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,