#[non_exhaustive]pub enum Limit {
Disabled,
Max(usize),
Unlimited,
}Expand description
Whether a Resource is cached, and how many of its entries are kept.
A limit counts in the resource’s scope (see Resource): Limit::Max(100) for
Resource::Member keeps up to 100 members in every guild, for Resource::Message up
to 100 messages in every channel. When a scope is full, inserting a new entry evicts the
one inserted first (D-157); updating an entry that is already cached does not change its
place.
discord.js counterpart: the numbers passed to Options.cacheWithLimits (0 disables a
manager’s cache, no entry means unlimited).
§Examples
use djs_cache::Limit;
assert!(Limit::Max(200).is_enabled());
assert_eq!(Limit::Max(200).max(), Some(200));
assert!(!Limit::Disabled.is_enabled());
// A maximum of zero keeps nothing; the configuration stores it as `Disabled`.
assert!(!Limit::Max(0).is_enabled());
assert_eq!(Limit::Unlimited.max(), None);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Disabled
The resource is not cached.
Max(usize)
At most this many entries per scope. Max(0) is the same as Limit::Disabled.
Unlimited
Every entry is kept.
Implementations§
Source§impl Limit
impl Limit
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 const fn max(self) -> Option<usize>
pub const fn max(self) -> Option<usize>
Returns the maximum number of entries per scope, or None if there is no maximum
(Limit::Unlimited) or nothing is cached (Limit::Disabled).
discord.js counterpart: the maxSize of LimitedCollection.