Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cache)!: Seal UpdateCache #1431

Merged
merged 4 commits into from
Jan 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion cache/in-memory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,68 @@ impl InMemoryCache {
}
}

mod private {
use twilight_model::gateway::{
event::Event,
payload::incoming::{
ChannelCreate, ChannelDelete, ChannelPinsUpdate, ChannelUpdate, GuildCreate,
GuildDelete, GuildEmojisUpdate, GuildStickersUpdate, GuildUpdate, IntegrationCreate,
IntegrationDelete, IntegrationUpdate, InteractionCreate, MemberAdd, MemberChunk,
MemberRemove, MemberUpdate, MessageCreate, MessageDelete, MessageDeleteBulk,
MessageUpdate, PresenceUpdate, ReactionAdd, ReactionRemove, ReactionRemoveAll,
ReactionRemoveEmoji, Ready, RoleCreate, RoleDelete, RoleUpdate, StageInstanceCreate,
StageInstanceDelete, StageInstanceUpdate, ThreadCreate, ThreadDelete, ThreadListSync,
ThreadUpdate, UnavailableGuild, UserUpdate, VoiceStateUpdate,
},
};

pub trait Sealed {}

impl Sealed for Event {}
impl Sealed for ChannelCreate {}
impl Sealed for ChannelDelete {}
impl Sealed for ChannelPinsUpdate {}
impl Sealed for ChannelUpdate {}
impl Sealed for GuildEmojisUpdate {}
impl Sealed for GuildCreate {}
impl Sealed for GuildDelete {}
impl Sealed for GuildUpdate {}
impl Sealed for IntegrationCreate {}
impl Sealed for IntegrationDelete {}
impl Sealed for IntegrationUpdate {}
impl Sealed for InteractionCreate {}
impl Sealed for MemberAdd {}
impl Sealed for MemberChunk {}
impl Sealed for MemberRemove {}
impl Sealed for MemberUpdate {}
impl Sealed for MessageCreate {}
impl Sealed for MessageDelete {}
impl Sealed for MessageDeleteBulk {}
impl Sealed for MessageUpdate {}
impl Sealed for PresenceUpdate {}
impl Sealed for ReactionAdd {}
impl Sealed for ReactionRemove {}
impl Sealed for ReactionRemoveAll {}
impl Sealed for ReactionRemoveEmoji {}
impl Sealed for RoleCreate {}
impl Sealed for RoleDelete {}
impl Sealed for RoleUpdate {}
impl Sealed for StageInstanceCreate {}
impl Sealed for StageInstanceDelete {}
impl Sealed for StageInstanceUpdate {}
impl Sealed for GuildStickersUpdate {}
impl Sealed for ThreadCreate {}
impl Sealed for ThreadDelete {}
impl Sealed for ThreadListSync {}
impl Sealed for ThreadUpdate {}
impl Sealed for VoiceStateUpdate {}
impl Sealed for Ready {}
impl Sealed for UnavailableGuild {}
impl Sealed for UserUpdate {}
vilgotf marked this conversation as resolved.
Show resolved Hide resolved
itohatweb marked this conversation as resolved.
Show resolved Hide resolved
itohatweb marked this conversation as resolved.
Show resolved Hide resolved
}

/// Implemented for dispatch events.
pub trait UpdateCache {
pub trait UpdateCache: private::Sealed {
vilgotf marked this conversation as resolved.
Show resolved Hide resolved
/// Updates the cache based on data contained within an event.
// Allow this for presentation purposes in documentation.
#[allow(unused_variables)]
Expand Down