pub struct InMemoryCacheStats<'a>(/* 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::InMemoryCache;

let cache = InMemoryCache::new();

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

Implementations§

source§

impl<'a> InMemoryCacheStats<'a>

source

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

Return an immutable reference to the underlying cache.

source

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

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> Clone for InMemoryCacheStats<'a>

source§

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

Returns a copy 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> Debug for InMemoryCacheStats<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for InMemoryCacheStats<'a>

§

impl<'a> Send for InMemoryCacheStats<'a>

§

impl<'a> Sync for InMemoryCacheStats<'a>

§

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

§

impl<'a> !UnwindSafe for InMemoryCacheStats<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.