pub struct ChannelView<'a, K, V, B>{ /* private fields */ }Expand description
A resource kept per channel (messages), for one channel, as returned by
Cache::messages.
A view of a disabled resource is empty. Every read is a snapshot: the cache may change right after it.
discord.js counterpart: channel.messages.cache.
§Examples
use djs_cache::{Cache, CacheConfig, Limit};
use djs_model::id::{ChannelId, MessageId};
let cache = Cache::with_config(CacheConfig::builder().messages(Limit::Max(100)).build());
let messages = cache.messages(ChannelId::new(1));
assert!(messages.is_enabled());
assert!(messages.get(MessageId::new(2)).is_none());Implementations§
Source§impl<'a, K, V, B> ChannelView<'a, K, V, B>
impl<'a, K, V, B> ChannelView<'a, K, V, B>
Sourcepub const fn channel_id(&self) -> ChannelId
pub const fn channel_id(&self) -> ChannelId
Returns the channel this view is about.
discord.js counterpart: a channel manager’s channel.
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 channel’s 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 the channel has a cached entry with this ID.
discord.js counterpart: Collection#has.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of the channel’s cached entries.
discord.js counterpart: Collection#size.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether nothing of the channel is cached.
discord.js counterpart: cache.size === 0.