Skip to content

Commit

Permalink
feat(cache)!: seal UpdateCache (#1431)
Browse files Browse the repository at this point in the history
As C-SEALED recommends, most of Twilight's traits are already sealed.
  • Loading branch information
vilgotf authored Jan 14, 2022
1 parent 8f55e43 commit e609cad
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion cache/in-memory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,70 @@ 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 GuildCreate {}
impl Sealed for GuildEmojisUpdate {}
impl Sealed for GuildDelete {}
impl Sealed for GuildStickersUpdate {}
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 Ready {}
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 ThreadCreate {}
impl Sealed for ThreadDelete {}
impl Sealed for ThreadListSync {}
impl Sealed for ThreadUpdate {}
impl Sealed for UnavailableGuild {}
impl Sealed for UserUpdate {}
impl Sealed for VoiceStateUpdate {}
}

/// Implemented for dispatch events.
pub trait UpdateCache {
///
/// This trait is sealed and cannot be implemented.
pub trait UpdateCache: private::Sealed {
/// Updates the cache based on data contained within an event.
// Allow this for presentation purposes in documentation.
#[allow(unused_variables)]
Expand Down

0 comments on commit e609cad

Please sign in to comment.