pub struct CacheView<'a, K, V, B>{ /* private fields */ }Expand description
A resource kept over the whole cache (guilds, channels, users), as returned by
Cache::guilds, Cache::channels and
Cache::users.
A view of a disabled resource is empty. Every read is a snapshot: the cache may change right after it.
discord.js counterpart: client.guilds.cache, client.channels.cache, client.users.cache.
§Examples
use djs_cache::Cache;
use djs_model::id::GuildId;
let cache = Cache::new();
let guilds = cache.guilds();
assert!(guilds.is_enabled());
assert!(guilds.get(GuildId::new(1)).is_none());
assert_eq!(guilds.len(), 0);Implementations§
Source§impl<'a, K, V, B> CacheView<'a, K, V, B>
impl<'a, K, V, B> CacheView<'a, K, V, B>
Sourcepub const fn is_enabled(&self) -> bool
pub const fn is_enabled(&self) -> bool
Returns whether the resource is cached at all.
discord.js counterpart: none (a manager’s cache always exists in discord.js).
Sourcepub fn get(&self, id: K) -> Option<Arc<V>>
pub fn get(&self, id: K) -> Option<Arc<V>>
Returns the entry with this ID.
discord.js counterpart: Collection#get.
Sourcepub fn contains(&self, id: K) -> bool
pub fn contains(&self, id: K) -> bool
Returns whether an entry with this ID is cached.
discord.js counterpart: Collection#has.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of cached entries.
discord.js counterpart: Collection#size.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether nothing is cached.
discord.js counterpart: cache.size === 0.
Trait Implementations§
Auto Trait Implementations§
impl<'a, K, V, B> !RefUnwindSafe for CacheView<'a, K, V, B>
impl<'a, K, V, B> !UnwindSafe for CacheView<'a, K, V, B>
impl<'a, K, V, B> Freeze for CacheView<'a, K, V, B>
impl<'a, K, V, B> Send for CacheView<'a, K, V, B>
impl<'a, K, V, B> Sync for CacheView<'a, K, V, B>
impl<'a, K, V, B> Unpin for CacheView<'a, K, V, B>
impl<'a, K, V, B> UnsafeUnpin for CacheView<'a, K, V, B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more