pub trait Cache: Backend {
Show 20 methods
// Required methods
fn current_user<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<CurrentUser, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn channel<'life0, 'async_trait>(
&'life0 self,
channel_id: Id<ChannelMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedChannel>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn private_channel<'life0, 'async_trait>(
&'life0 self,
recipient_id: Id<UserMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<Id<ChannelMarker>>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn guild<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedGuild>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn emoji<'life0, 'async_trait>(
&'life0 self,
emoji_id: Id<EmojiMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedEmoji>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn sticker<'life0, 'async_trait>(
&'life0 self,
sticker_id: Id<StickerMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedSticker>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn member<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
user_id: Id<UserMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedMember>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn message<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedMessage>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn attachments<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedAttachment>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn stickers<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedMessageSticker>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn reactions<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedReaction>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn role<'life0, 'async_trait>(
&'life0 self,
role_id: Id<RoleMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedRole>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn member_roles<'life0, 'async_trait>(
&'life0 self,
user_id: Id<UserMarker>,
guild_id: Id<GuildMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedRole>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn stage_instance<'life0, 'async_trait>(
&'life0 self,
stage_id: Id<StageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<StageInstance>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = Result<(), Error<Self::Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn self_channel_permissions<'life0, 'async_trait>(
&'life0 self,
channel_id: Id<ChannelMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn self_guild_permissions<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn channel_permissions<'life0, 'async_trait>(
&'life0 self,
user_id: Id<UserMarker>,
channel_id: Id<ChannelMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn guild_permissions<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
user_id: Id<UserMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn embeds<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(CachedEmbed, Vec<CachedEmbedField>)>, Error<Self::Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Required Methods§
Sourcefn current_user<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<CurrentUser, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn current_user<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<CurrentUser, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the current user information of the bot
§Errors
Returns Error::CurrentUserMissing when called before the ready event
is received
Sourcefn channel<'life0, 'async_trait>(
&'life0 self,
channel_id: Id<ChannelMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedChannel>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn channel<'life0, 'async_trait>(
&'life0 self,
channel_id: Id<ChannelMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedChannel>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a cached channel or thread by its ID
The users that are joined in a thread aren’t cached, as caching them is likely unnecessary, if you need them, please create an issue
Sourcefn private_channel<'life0, 'async_trait>(
&'life0 self,
recipient_id: Id<UserMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<Id<ChannelMarker>>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn private_channel<'life0, 'async_trait>(
&'life0 self,
recipient_id: Id<UserMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<Id<ChannelMarker>>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a DM channel’s ID by its recipient’s ID
Since DM channels can’t be deleted consistently and efficiently, you should make sure the bot shares a guild with the recipient
Sourcefn guild<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedGuild>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn guild<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedGuild>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a cached guild by its ID
Sourcefn emoji<'life0, 'async_trait>(
&'life0 self,
emoji_id: Id<EmojiMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedEmoji>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn emoji<'life0, 'async_trait>(
&'life0 self,
emoji_id: Id<EmojiMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedEmoji>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a cached emoji by its ID
Sourcefn sticker<'life0, 'async_trait>(
&'life0 self,
sticker_id: Id<StickerMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedSticker>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn sticker<'life0, 'async_trait>(
&'life0 self,
sticker_id: Id<StickerMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedSticker>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a cached sticker by its ID
Sourcefn member<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
user_id: Id<UserMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedMember>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn member<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
user_id: Id<UserMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedMember>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a cached member by its guild ID and user ID
Sourcefn message<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedMessage>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn message<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedMessage>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a cached message by its ID
The returned message doesn’t contain embeds, attachments, reactions or stickers, since they’re cached separately and the method doesn’t query them for you to reduce overhead in case you don’t need them
Sourcefn attachments<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedAttachment>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn attachments<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedAttachment>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get cached attachments of a message by its ID
Sourcefn stickers<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedMessageSticker>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stickers<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedMessageSticker>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get cached stickers of a message by its ID
Sourcefn reactions<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedReaction>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reactions<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedReaction>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get cached reactions of a message by its ID
Sourcefn role<'life0, 'async_trait>(
&'life0 self,
role_id: Id<RoleMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedRole>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn role<'life0, 'async_trait>(
&'life0 self,
role_id: Id<RoleMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedRole>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a cached role by its ID
Sourcefn member_roles<'life0, 'async_trait>(
&'life0 self,
user_id: Id<UserMarker>,
guild_id: Id<GuildMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedRole>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn member_roles<'life0, 'async_trait>(
&'life0 self,
user_id: Id<UserMarker>,
guild_id: Id<GuildMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<CachedRole>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get cached roles of a member by their ID
Sourcefn stage_instance<'life0, 'async_trait>(
&'life0 self,
stage_id: Id<StageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<StageInstance>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stage_instance<'life0, 'async_trait>(
&'life0 self,
stage_id: Id<StageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Option<StageInstance>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a cached stage instance by its ID
Provided Methods§
Sourcefn update<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = Result<(), Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = Result<(), Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update the cache with the given event, should be called for every event to keep the cache valid
§Clones
Many events don’t require the event to be cloned, so the event parameter is taken by a reference, if an event does require a clone (usually add and update events), it will clone the required fields
§Errors
Returns the error the backend might return
On twilight_model::gateway::event::Event::ChannelCreate,
twilight_model::gateway::event::Event::ChannelUpdate and
twilight_model::gateway::event::Event::ChannelDelete, events when
the channel is a DM channel, might return
Error::PrivateChannelMissingRecipient
Sourcefn self_channel_permissions<'life0, 'async_trait>(
&'life0 self,
channel_id: Id<ChannelMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn self_channel_permissions<'life0, 'async_trait>(
&'life0 self,
channel_id: Id<ChannelMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Get permissions of the current user in the given channel
This is a convenience method for Self::channel_permissions with the
current user’s ID
§Errors
Returns the error the backend might return
Returns Error::PermissionsChannelMissing,
Error::PermissionsChannelNotInGuild,
Error::PermissionsGuildMissing or
Error::PermissionsGuildEveryoneRoleMissing
Sourcefn self_guild_permissions<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn self_guild_permissions<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Get permissions of the current user in the given guild
This is a convenience method for Self::guild_permissions with the
current user’s ID
§Errors
Returns the error the backend might return
Returns Error::PermissionsGuildMissing or
Error::PermissionsGuildEveryoneRoleMissing
Sourcefn channel_permissions<'life0, 'async_trait>(
&'life0 self,
user_id: Id<UserMarker>,
channel_id: Id<ChannelMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn channel_permissions<'life0, 'async_trait>(
&'life0 self,
user_id: Id<UserMarker>,
channel_id: Id<ChannelMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Get the permissions of the given user and channel
§Errors
Returns the error the backend might return
Returns Error::PermissionsChannelMissing,
Error::PermissionsChannelNotInGuild,
Error::PermissionsGuildMissing,
Error::PermissionsGuildEveryoneRoleMissing,
Error::PermissionsMemberMissing or
Error::MemberBadTimeoutTimestamp
Sourcefn guild_permissions<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
user_id: Id<UserMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn guild_permissions<'life0, 'async_trait>(
&'life0 self,
guild_id: Id<GuildMarker>,
user_id: Id<UserMarker>,
) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Get the permissions of the given user and guild
§Errors
Returns the error the backend might return
Returns Error::PermissionsGuildMissing,
Error::PermissionsGuildEveryoneRoleMissing,
Error::PermissionsMemberMissing or
Error::MemberBadTimeoutTimestamp
Sourcefn embeds<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(CachedEmbed, Vec<CachedEmbedField>)>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn embeds<'life0, 'async_trait>(
&'life0 self,
message_id: Id<MessageMarker>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(CachedEmbed, Vec<CachedEmbedField>)>, Error<Self::Error>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Get cached embeds of a message by its ID