pub struct CacheConfigBuilder { /* private fields */ }Expand description
Builds a CacheConfig. Created by CacheConfig::builder, or from an existing
configuration with CacheConfigBuilder::from.
Every method sets the Limit of one Resource; resources not mentioned keep the
starting configuration’s limit.
§Examples
Start from discord.js’ defaults and turn presences off:
use djs_cache::{CacheConfig, CacheConfigBuilder, Limit, Resource};
let config = CacheConfigBuilder::from(CacheConfig::discord_js())
.presences(Limit::Disabled)
.build();
assert!(!config.is_enabled(Resource::Presence));
assert!(config.is_enabled(Resource::Member));Implementations§
Source§impl CacheConfigBuilder
impl CacheConfigBuilder
Sourcepub const fn limit(self, resource: Resource, limit: Limit) -> Self
pub const fn limit(self, resource: Resource, limit: Limit) -> Self
Sets the limit of any resource.
discord.js counterpart: a manager’s entry in Options.cacheWithLimits.
Sourcepub const fn guilds(self, limit: Limit) -> Self
pub const fn guilds(self, limit: Limit) -> Self
Sets the limit of Resource::Guild (default Limit::Unlimited).
discord.js counterpart: the GuildManager entry of Options.cacheWithLimits.
Sourcepub const fn channels(self, limit: Limit) -> Self
pub const fn channels(self, limit: Limit) -> Self
Sets the limit of Resource::Channel (default Limit::Unlimited).
discord.js counterpart: the ChannelManager entry of Options.cacheWithLimits.
Sourcepub const fn threads(self, limit: Limit) -> Self
pub const fn threads(self, limit: Limit) -> Self
Sets the limit of Resource::Thread, per guild (default Limit::Disabled).
discord.js counterpart: the ThreadManager entry of Options.cacheWithLimits.
Sourcepub const fn roles(self, limit: Limit) -> Self
pub const fn roles(self, limit: Limit) -> Self
Sets the limit of Resource::Role, per guild (default Limit::Unlimited).
discord.js counterpart: the RoleManager entry of Options.cacheWithLimits.
Sourcepub const fn emojis(self, limit: Limit) -> Self
pub const fn emojis(self, limit: Limit) -> Self
Sets the limit of Resource::Emoji, per guild (default Limit::Disabled).
discord.js counterpart: the GuildEmojiManager entry of Options.cacheWithLimits.
Sourcepub const fn stickers(self, limit: Limit) -> Self
pub const fn stickers(self, limit: Limit) -> Self
Sets the limit of Resource::Sticker, per guild (default Limit::Disabled).
discord.js counterpart: the GuildStickerManager entry of Options.cacheWithLimits.
Sourcepub const fn members(self, limit: Limit) -> Self
pub const fn members(self, limit: Limit) -> Self
Sets the limit of Resource::Member, per guild (default Limit::Disabled).
discord.js counterpart: the GuildMemberManager entry of Options.cacheWithLimits.
Sourcepub const fn users(self, limit: Limit) -> Self
pub const fn users(self, limit: Limit) -> Self
Sets the limit of Resource::User (default Limit::Disabled).
discord.js counterpart: the UserManager entry of Options.cacheWithLimits.
Sourcepub const fn messages(self, limit: Limit) -> Self
pub const fn messages(self, limit: Limit) -> Self
Sets the limit of Resource::Message, per channel (default Limit::Disabled).
discord.js counterpart: the MessageManager entry of Options.cacheWithLimits.
Sourcepub const fn presences(self, limit: Limit) -> Self
pub const fn presences(self, limit: Limit) -> Self
Sets the limit of Resource::Presence, per guild (default Limit::Disabled).
discord.js counterpart: the PresenceManager entry of Options.cacheWithLimits.
Sourcepub const fn voice_states(self, limit: Limit) -> Self
pub const fn voice_states(self, limit: Limit) -> Self
Sets the limit of Resource::VoiceState, per guild (default Limit::Disabled).
discord.js counterpart: the VoiceStateManager entry of Options.cacheWithLimits.
Sourcepub const fn scheduled_events(self, limit: Limit) -> Self
pub const fn scheduled_events(self, limit: Limit) -> Self
Sets the limit of Resource::ScheduledEvent, per guild (default
Limit::Disabled).
discord.js counterpart: the GuildScheduledEventManager entry of Options.cacheWithLimits.
Sourcepub const fn stage_instances(self, limit: Limit) -> Self
pub const fn stage_instances(self, limit: Limit) -> Self
Sets the limit of Resource::StageInstance, per guild (default
Limit::Disabled).
discord.js counterpart: the StageInstanceManager entry of Options.cacheWithLimits.
Sourcepub const fn soundboard_sounds(self, limit: Limit) -> Self
pub const fn soundboard_sounds(self, limit: Limit) -> Self
Sets the limit of Resource::SoundboardSound, per guild (default
Limit::Disabled).
discord.js counterpart: the GuildSoundboardSoundManager entry of Options.cacheWithLimits.
Sourcepub const fn sweep_messages(self, sweep: Option<Sweep>) -> Self
pub const fn sweep_messages(self, sweep: Option<Sweep>) -> Self
Sets the periodic sweep of old messages (default none: messages are bounded by their
limit). See Cache::sweep_messages_older_than.
discord.js counterpart: the messages key of the sweepers client option.
Sourcepub const fn sweep_threads(self, sweep: Option<Sweep>) -> Self
pub const fn sweep_threads(self, sweep: Option<Sweep>) -> Self
Sets the periodic sweep of long-archived threads (default every hour, archived more
than 4 hours ago). See Cache::sweep_archived_threads.
discord.js counterpart: the threads key of the sweepers client option.
Sourcepub fn build(self) -> CacheConfig
pub fn build(self) -> CacheConfig
Builds the configuration.
discord.js counterpart: Options.cacheWithLimits.
Trait Implementations§
Source§impl Clone for CacheConfigBuilder
impl Clone for CacheConfigBuilder
Source§impl Debug for CacheConfigBuilder
impl Debug for CacheConfigBuilder
Source§impl From<CacheConfig> for CacheConfigBuilder
impl From<CacheConfig> for CacheConfigBuilder
Source§fn from(config: CacheConfig) -> Self
fn from(config: CacheConfig) -> Self
Starts a builder from an existing configuration.