Struct InMemoryCacheStats

Source
pub struct InMemoryCacheStats<'a, CacheModels: CacheableModels = DefaultCacheModels>(/* private fields */);
Expand description

Retrieve statistics about the number of entities of each resource in the cache.

Statistics can be retrieved about the amount of resources on a cache-level via a method such as users or in a particular channel via a method such as channel_messages.

§Examples

Retrieve the number of users stored in the cache:

use twilight_cache_inmemory::DefaultInMemoryCache;

let cache = DefaultInMemoryCache::new();

// later on...
println!("user count: {}", cache.stats().users());

Implementations§

Source§

impl<'a, CacheModels: CacheableModels> InMemoryCacheStats<'a, CacheModels>

Source

pub const fn cache_ref(&'a self) -> &'a InMemoryCache<CacheModels>

Return an immutable reference to the underlying cache.

Source

pub const fn into_cache(self) -> &'a InMemoryCache<CacheModels>

Consume the statistics interface, returning the underlying cache reference.

Source

pub fn channels(&self) -> usize

Number of channels in the cache.

Source

pub fn channel_messages(&self, channel_id: Id<ChannelMarker>) -> Option<usize>

Number of messages in a given channel in the cache.

Returns None if the channel hasn’t yet been cached or there are no messages in the channel. However, the provided number may still be 0 if some number is returned.

Source

pub fn channel_voice_states( &self, channel_id: Id<ChannelMarker>, ) -> Option<usize>

Number of voice states in a given channel in the cache.

Returns None if the channel hasn’t yet been cached or there are no voice states in the channel. However, the provided number may still be 0 if some number is returned.

Source

pub fn emojis(&self) -> usize

Number of emojis in the cache.

Source

pub fn guilds(&self) -> usize

Number of guilds in the cache.

Source

pub fn guild_channels(&self, guild_id: Id<GuildMarker>) -> Option<usize>

Number of channels in a given guild in the cache.

Returns None if the guild hasn’t yet been cached.

Source

pub fn guild_emojis(&self, guild_id: Id<GuildMarker>) -> Option<usize>

Number of emojis in a given guild in the cache.

Returns None if the guild hasn’t yet been cached.

Source

pub fn guild_members(&self, guild_id: Id<GuildMarker>) -> Option<usize>

Number of members in a given guild in the cache.

Returns None if the guild hasn’t yet been cached.

Source

pub fn guild_presences(&self, guild_id: Id<GuildMarker>) -> Option<usize>

Number of presences in a given guild in the cache.

Returns None if the guild hasn’t yet been cached.

Source

pub fn guild_roles(&self, guild_id: Id<GuildMarker>) -> Option<usize>

Number of roles in a given guild in the cache.

Returns None if the guild hasn’t yet been cached.

Source

pub fn guild_voice_states(&self, guild_id: Id<GuildMarker>) -> Option<usize>

Number of voice states in a given guild in the cache.

Returns None if the guild hasn’t yet been cached.

Source

pub fn members(&self) -> usize

Number of members in the cache.

Source

pub fn presences(&self) -> usize

Number of presences in the cache.

Source

pub fn roles(&self) -> usize

Number of roles in the cache.

Source

pub fn unavailable_guilds(&self) -> usize

Number of unavailable guilds in the cache.

Source

pub fn users(&self) -> usize

Number of users in the cache.

Source

pub fn voice_states(&self) -> usize

Number of voice states in the cache.

Trait Implementations§

Source§

impl<'a, CacheModels: Clone + CacheableModels> Clone for InMemoryCacheStats<'a, CacheModels>

Source§

fn clone(&self) -> InMemoryCacheStats<'a, CacheModels>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, CacheModels: Debug + CacheableModels> Debug for InMemoryCacheStats<'a, CacheModels>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, CacheModels> Freeze for InMemoryCacheStats<'a, CacheModels>

§

impl<'a, CacheModels = DefaultCacheModels> !RefUnwindSafe for InMemoryCacheStats<'a, CacheModels>

§

impl<'a, CacheModels> Send for InMemoryCacheStats<'a, CacheModels>
where <CacheModels as CacheableModels>::CurrentUser: Send, <CacheModels as CacheableModels>::Channel: Send + Sync, <CacheModels as CacheableModels>::Guild: Send + Sync, <CacheModels as CacheableModels>::Member: Send + Sync, <CacheModels as CacheableModels>::Message: Send + Sync, <CacheModels as CacheableModels>::Presence: Send + Sync, <CacheModels as CacheableModels>::User: Send + Sync, <CacheModels as CacheableModels>::VoiceState: Send + Sync, <CacheModels as CacheableModels>::Emoji: Send + Sync, <CacheModels as CacheableModels>::GuildIntegration: Send + Sync, <CacheModels as CacheableModels>::Role: Send + Sync, <CacheModels as CacheableModels>::GuildScheduledEvent: Send + Sync, <CacheModels as CacheableModels>::StageInstance: Send + Sync, <CacheModels as CacheableModels>::Sticker: Send + Sync,

§

impl<'a, CacheModels> Sync for InMemoryCacheStats<'a, CacheModels>
where <CacheModels as CacheableModels>::CurrentUser: Send, <CacheModels as CacheableModels>::Channel: Send + Sync, <CacheModels as CacheableModels>::Guild: Send + Sync, <CacheModels as CacheableModels>::Member: Send + Sync, <CacheModels as CacheableModels>::Message: Send + Sync, <CacheModels as CacheableModels>::Presence: Send + Sync, <CacheModels as CacheableModels>::User: Send + Sync, <CacheModels as CacheableModels>::VoiceState: Send + Sync, <CacheModels as CacheableModels>::Emoji: Send + Sync, <CacheModels as CacheableModels>::GuildIntegration: Send + Sync, <CacheModels as CacheableModels>::Role: Send + Sync, <CacheModels as CacheableModels>::GuildScheduledEvent: Send + Sync, <CacheModels as CacheableModels>::StageInstance: Send + Sync, <CacheModels as CacheableModels>::Sticker: Send + Sync,

§

impl<'a, CacheModels> Unpin for InMemoryCacheStats<'a, CacheModels>

§

impl<'a, CacheModels = DefaultCacheModels> !UnwindSafe for InMemoryCacheStats<'a, CacheModels>

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, 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> 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.