pub trait UpdateCache: Sealed {
type Previous;
}Expand description
A gateway event payload the cache can apply, with the type of the previous state it returns (D-163).
Use it through Cache::update; for a whole [DispatchEvent] use
Cache::update_dispatch. Every update borrows the event and copies what the cache keeps
(D-161). The previous state is what the event replaced or removed, or nothing when the
resource is disabled or the entry was not cached; for a guild it is the guild itself, not
its roles, channels or members.
| Payload | What it does | Previous |
|---|---|---|
[Ready] | sets the current user; lists the guilds as unavailable | Option<Arc<CurrentUser>> |
[UserUpdate] | replaces the current user | Option<Arc<CurrentUser>> |
[GuildCreate] | caches the guild with its channels, roles, emojis, stickers and members | Option<Arc<CachedGuild>> |
[GuildUpdate] | updates the guild (and its roles, emojis, stickers if sent) | Option<Arc<CachedGuild>> |
[GuildDelete] | removes the guild and everything in it, or marks it unavailable during an outage | Option<Arc<CachedGuild>> |
[ChannelCreate], [ChannelUpdate] | caches the channel (threads are skipped) | Option<Arc<Channel>> |
[ChannelDelete] | removes the channel | Option<Arc<Channel>> |
[ChannelPinsUpdate] | sets the channel’s last pin time | Option<Arc<Channel>> |
[GuildRoleCreate], [GuildRoleUpdate] | caches the role | Option<Arc<Role>> |
[GuildRoleDelete] | removes the role | Option<Arc<Role>> |
[GuildEmojisUpdate] | replaces the guild’s emojis | Vec<Arc<Emoji>> |
[GuildStickersUpdate] | replaces the guild’s stickers | Vec<Arc<Sticker>> |
[GuildMemberAdd] | caches the member, counts it in the guild | Option<Arc<CachedMember>> |
[GuildMemberUpdate] | updates (or adds) the member | Option<Arc<CachedMember>> |
[GuildMemberRemove] | removes the member, uncounts it | Option<Arc<CachedMember>> |
[GuildMembersChunk] | caches the members (and their presences) | Vec<Arc<CachedMember>> (those replaced) |
[MessageCreate] | caches the message (author as a user, its member as a member) | Option<Arc<CachedMessage>> |
[MessageUpdate] | replaces a cached message | Option<Arc<CachedMessage>> |
[MessageDelete] | removes the message | Option<Arc<CachedMessage>> |
[MessageDeleteBulk] | removes the messages | Vec<Arc<CachedMessage>> |
[MessageReactionAdd], [MessageReactionRemove], [MessageReactionRemoveAll], [MessageReactionRemoveEmoji] | updates a cached message’s reactions | Option<Arc<CachedMessage>> |
[TypingStart] | caches the typing member (in a guild) | Option<Arc<CachedMember>> |
[InteractionCreate] | caches the interaction’s user and member, and the resolved users and members (not the resolved partial channels) | Option<Arc<CachedMember>> (the interaction’s member) |
[PresenceUpdate] | caches the presence, or removes it when offline | Option<Arc<CachedPresence>> |
[VoiceStateUpdate] | caches the voice state, or removes it when the user left voice | Option<Arc<VoiceState>> |
[ThreadCreate], [ThreadUpdate] | caches the thread | Option<Arc<Channel>> |
[ThreadDelete] | removes the thread and its messages | Option<Arc<Channel>> |
[ThreadListSync] | replaces the synced channels’ active threads | Vec<Arc<Channel>> |
[ThreadMembersUpdate] | sets the thread’s member count; caches the added members as guild members | Option<Arc<Channel>> |
[GuildScheduledEventCreate], [GuildScheduledEventUpdate], [GuildScheduledEventDelete] | caches / removes the event | Option<Arc<GuildScheduledEvent>> |
[StageInstanceCreate], [StageInstanceUpdate], [StageInstanceDelete] | caches / removes the stage instance | Option<Arc<StageInstance>> |
[GuildSoundboardSoundCreate], [GuildSoundboardSoundUpdate], [GuildSoundboardSoundDelete] | caches / removes the sound | Option<Arc<SoundboardSound>> |
[GuildSoundboardSoundsUpdate] | caches the sounds | Vec<Arc<SoundboardSound>> (those replaced) |
[SoundboardSounds] | replaces the guild’s sounds | Vec<Arc<SoundboardSound>> |
Users seen in member events are cached too when Resource::User
is enabled.
This trait is sealed: the cache implements it for the payloads it understands.
discord.js counterpart: the client’s internal actions (client.actions.GuildMemberUpdate,
…), which also return the old and new state.
Required Associated Types§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".