[−][src]Struct tbot::state::chats::Chats
A store for state per chat. See module docs to learn how to use it.
Methods
impl<S> Chats<S>
[src]
#[must_use]pub fn new() -> Self
[src]
Constructs a new chat store.
#[must_use]pub fn with_capacity(capacity: usize) -> Self
[src]
Constructs a new chat store with capacity for n
chats.
pub fn chats(&self) -> impl Iterator<Item = Id> + '_
[src]
Returns an iterator over stored chat IDs.
pub fn states(&self) -> impl Iterator<Item = &S>
[src]
Returns an iterator over stored states.
pub fn iter(&self) -> impl Iterator<Item = (Id, &S)>
[src]
Returns an iterator over stored chat IDs and their states behind an immutable reference.
pub fn iter_mut(&mut self) -> impl Iterator<Item = (Id, &mut S)>
[src]
Returns an iterator over stored chat IDs and their states behind a mutable reference.
#[must_use]pub fn len(&self) -> usize
[src]
Returns how many chats are stored.
#[must_use]pub fn capacity(&self) -> usize
[src]
Returns the capacity of the store.
#[must_use]pub fn is_empty(&self) -> bool
[src]
Returns if the store is empty.
#[must_use = "use `clear` if you don't need the iterator"]pub fn drain(&mut self) -> impl Iterator<Item = (Id, S)> + '_
[src]
Clears the store, returning each stored item in an iterator.
pub fn clear(&mut self)
[src]
Clears the store.
pub fn reserve(&mut self, additional: usize)
[src]
Reserves capacity for additional n
chats.
pub fn shrink_to_fit(&mut self)
[src]
Shrinks the store to store only already stored chats.
#[must_use]pub fn get_by_id(&self, id: Id) -> Option<&S>
[src]
Gets a chat's state by its ID.
#[must_use]pub fn get<Ctx, Con>(&self, context: &Ctx) -> Option<&S> where
Ctx: Message<Con>,
[src]
Ctx: Message<Con>,
Gets a chat's state by the context.
#[must_use]pub fn get_mut_by_id(&mut self, id: Id) -> Option<&mut S>
[src]
Gets a mutable reference to a chat's state by its ID.
#[must_use]pub fn get_mut<Ctx, Con>(&mut self, context: &Ctx) -> Option<&mut S> where
Ctx: Message<Con>,
[src]
Ctx: Message<Con>,
Gets a mutable reference to a chat's state by the context.
#[must_use]pub fn entry_by_id(&mut self, id: Id) -> Entry<Id, S>
[src]
Gets an entry for a chat's state by its ID.
#[must_use]pub fn entry<Ctx, Con>(&mut self, context: &Ctx) -> Entry<Id, S> where
Ctx: Message<Con>,
[src]
Ctx: Message<Con>,
Gets an entry for a chat's state by the context.
#[must_use]pub fn has_by_id(&self, id: Id) -> bool
[src]
Checks if there's state for a chat by its ID.
#[must_use]pub fn has<Ctx, Con>(&self, context: &Ctx) -> bool where
Ctx: Message<Con>,
[src]
Ctx: Message<Con>,
Checks if there's state for a chat by the context.
pub fn insert_by_id(&mut self, id: Id, value: S) -> Option<S>
[src]
Inserts state for a chat by its ID. Returns the previous state.
pub fn insert<Ctx, Con>(&mut self, context: &Ctx, value: S) -> Option<S> where
Ctx: Message<Con>,
[src]
Ctx: Message<Con>,
Inserts state for a chat by the context. Returns the previous state.
pub fn remove_by_id(&mut self, id: Id) -> Option<S>
[src]
Removes and returns a chat's state by its ID.
pub fn remove<Ctx, Con>(&mut self, context: &Ctx) -> Option<S> where
Ctx: Message<Con>,
[src]
Ctx: Message<Con>,
Removes and returns a chat's state by the context.
pub fn retain<P>(&mut self, predicate: P) where
P: FnMut(Id, &mut S) -> bool,
[src]
P: FnMut(Id, &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 Chats<S>
[src]
impl<S: Debug> Debug for Chats<S>
[src]
impl<S> Default for Chats<S>
[src]
impl<'de, S> Deserialize<'de> for Chats<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 Chats<S>
[src]
impl<'a, S: Copy> Extend<(Id, &'a S)> for Chats<S>
[src]
impl<S> Extend<(Id, S)> for Chats<S>
[src]
impl<S> FromIterator<(Id, S)> for Chats<S>
[src]
impl<S> Index<Id> for Chats<S>
[src]
impl<S> IntoIterator for Chats<S>
[src]
type Item = (Id, S)
The type of the elements being iterated over.
type IntoIter = IntoIter<Id, S>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, S> IntoIterator for &'a Chats<S>
[src]
type Item = (Id, &'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 Chats<S>
[src]
type Item = (Id, &'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<Chats<S>> for Chats<S>
[src]
impl<S> Serialize for Chats<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 Chats<S>
[src]
impl<S> StructuralPartialEq for Chats<S>
[src]
Auto Trait Implementations
impl<S> RefUnwindSafe for Chats<S> where
S: RefUnwindSafe,
S: RefUnwindSafe,
impl<S> Send for Chats<S> where
S: Send,
S: Send,
impl<S> Sync for Chats<S> where
S: Sync,
S: Sync,
impl<S> Unpin for Chats<S> where
S: Unpin,
S: Unpin,
impl<S> UnwindSafe for Chats<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: Deserialize<'de>,
[src]
T: 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>,