Skip to main content

CacheConfigBuilder

Struct CacheConfigBuilder 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn build(self) -> CacheConfig

Builds the configuration.

discord.js counterpart: Options.cacheWithLimits.

Trait Implementations§

Source§

impl Clone for CacheConfigBuilder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CacheConfigBuilder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<CacheConfig> for CacheConfigBuilder

Source§

fn from(config: CacheConfig) -> Self

Starts a builder from an existing configuration.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.