Struct twilight_gateway::EventTypeFlags
source · pub struct EventTypeFlags(/* private fields */);
Expand description
Important optimization for narrowing requested event types.
Specifying event types is an important optimization technique on top of
Intents
, which can dramatically decrease processor usage in many
circumstances. While specifying intents are required by Discord and
allow filtering groups of Event
s, event type flags are a
Twilight-specific technique to filter out individual events from being
deserialized at all, effectively discarding them.
For example, Intents::GUILDS
includes a wide range of events from
GuildCreate
to RoleUpdate
to ChannelPinsUpdate
. If the only
events used in this group of events is, say, ChannelCreate
and
RoleCreate
, then the CHANNEL_CREATE
and
ROLE_CREATE
event type flags can be specified in
combination with that intent to only deserialize those events.
Selected event types only affect the events returned by Shard
s.
Events necessary for maintaining the connection to Discord, such as
GATEWAY_HEARTBEAT
and
GATEWAY_HELLO
, can safely be excluded and
won’t cause the operation of shards to fail, because shards will always
parse portions of necessary events.
Implementations§
source§impl EventTypeFlags
impl EventTypeFlags
sourcepub const AUTO_MODERATION_ACTION_EXECUTION: Self = _
pub const AUTO_MODERATION_ACTION_EXECUTION: Self = _
Message has been blocked by AutoMod according to a rule.
sourcepub const AUTO_MODERATION_RULE_CREATE: Self = _
pub const AUTO_MODERATION_RULE_CREATE: Self = _
AutoModerationRule
has been created.
sourcepub const AUTO_MODERATION_RULE_DELETE: Self = _
pub const AUTO_MODERATION_RULE_DELETE: Self = _
AutoModerationRule
has been deleted.
sourcepub const AUTO_MODERATION_RULE_UPDATE: Self = _
pub const AUTO_MODERATION_RULE_UPDATE: Self = _
AutoModerationRule
has been updated.
sourcepub const BAN_REMOVE: Self = _
pub const BAN_REMOVE: Self = _
User has been unbanned from a guild.
sourcepub const CHANNEL_CREATE: Self = _
pub const CHANNEL_CREATE: Self = _
Channel has been created.
sourcepub const CHANNEL_DELETE: Self = _
pub const CHANNEL_DELETE: Self = _
Channel has been deleted.
sourcepub const CHANNEL_PINS_UPDATE: Self = _
pub const CHANNEL_PINS_UPDATE: Self = _
Channel’s pins have been updated.
sourcepub const CHANNEL_UPDATE: Self = _
pub const CHANNEL_UPDATE: Self = _
Channel has been updated.
sourcepub const COMMAND_PERMISSIONS_UPDATE: Self = _
pub const COMMAND_PERMISSIONS_UPDATE: Self = _
A command’s permissions has been updated.
sourcepub const GATEWAY_HEARTBEAT: Self = _
pub const GATEWAY_HEARTBEAT: Self = _
Heartbeat has been created.
sourcepub const GATEWAY_HEARTBEAT_ACK: Self = _
pub const GATEWAY_HEARTBEAT_ACK: Self = _
Heartbeat has been acknowledged.
sourcepub const GATEWAY_HELLO: Self = _
pub const GATEWAY_HELLO: Self = _
A “hello” packet has been received from the gateway.
sourcepub const GATEWAY_INVALIDATE_SESSION: Self = _
pub const GATEWAY_INVALIDATE_SESSION: Self = _
Shard’s session has been invalidated.
A payload containing a boolean is included. If true
the session is
resumable. If not, then the shard must initialize a new session.
sourcepub const GATEWAY_RECONNECT: Self = _
pub const GATEWAY_RECONNECT: Self = _
Gateway is indicating that a shard should perform a reconnect.
sourcepub const GUILD_AUDIT_LOG_ENTRY_CREATE: Self = _
pub const GUILD_AUDIT_LOG_ENTRY_CREATE: Self = _
An audit log entry has been created.
sourcepub const GUILD_CREATE: Self = _
pub const GUILD_CREATE: Self = _
A guild has been created.
sourcepub const GUILD_DELETE: Self = _
pub const GUILD_DELETE: Self = _
A guild has been deleted or the current user has been removed from a guild.
sourcepub const GUILD_EMOJIS_UPDATE: Self = _
pub const GUILD_EMOJIS_UPDATE: Self = _
A guild’s emojis have been updated.
sourcepub const GUILD_INTEGRATIONS_UPDATE: Self = _
pub const GUILD_INTEGRATIONS_UPDATE: Self = _
A guild’s integrations have been updated.
sourcepub const GUILD_SCHEDULED_EVENT_CREATE: Self = _
pub const GUILD_SCHEDULED_EVENT_CREATE: Self = _
A guild’s integrations have been updated.
sourcepub const GUILD_SCHEDULED_EVENT_DELETE: Self = _
pub const GUILD_SCHEDULED_EVENT_DELETE: Self = _
A guild’s integrations have been updated.
sourcepub const GUILD_SCHEDULED_EVENT_UPDATE: Self = _
pub const GUILD_SCHEDULED_EVENT_UPDATE: Self = _
A guild’s integrations have been updated.
sourcepub const GUILD_SCHEDULED_EVENT_USER_ADD: Self = _
pub const GUILD_SCHEDULED_EVENT_USER_ADD: Self = _
A guild’s integrations have been updated.
sourcepub const GUILD_SCHEDULED_EVENT_USER_REMOVE: Self = _
pub const GUILD_SCHEDULED_EVENT_USER_REMOVE: Self = _
A guild’s integrations have been updated.
sourcepub const GUILD_STICKERS_UPDATE: Self = _
pub const GUILD_STICKERS_UPDATE: Self = _
A guild’s stickers have been updated.
sourcepub const GUILD_UPDATE: Self = _
pub const GUILD_UPDATE: Self = _
A guild has been updated.
sourcepub const INTEGRATION_CREATE: Self = _
pub const INTEGRATION_CREATE: Self = _
A guild integration was created.
sourcepub const INTEGRATION_DELETE: Self = _
pub const INTEGRATION_DELETE: Self = _
A guild integration was deleted.
sourcepub const INTEGRATION_UPDATE: Self = _
pub const INTEGRATION_UPDATE: Self = _
A guild integration was updated.
sourcepub const INTERACTION_CREATE: Self = _
pub const INTERACTION_CREATE: Self = _
An interaction was invoked by a user.
sourcepub const INVITE_CREATE: Self = _
pub const INVITE_CREATE: Self = _
Invite for a channel has been created.
sourcepub const INVITE_DELETE: Self = _
pub const INVITE_DELETE: Self = _
Invite for a channel has been deleted.
sourcepub const MEMBER_ADD: Self = _
pub const MEMBER_ADD: Self = _
Member has been added to a guild.
sourcepub const MEMBER_REMOVE: Self = _
pub const MEMBER_REMOVE: Self = _
Member has been removed from a guild.
sourcepub const MEMBER_UPDATE: Self = _
pub const MEMBER_UPDATE: Self = _
Member in a guild has been updated.
sourcepub const MEMBER_CHUNK: Self = _
pub const MEMBER_CHUNK: Self = _
Group of members from a guild.
This may be all of the remaining members or not; the chunk index in the event payload needs to be confirmed.
sourcepub const MESSAGE_CREATE: Self = _
pub const MESSAGE_CREATE: Self = _
Message created in a channel.
sourcepub const MESSAGE_DELETE: Self = _
pub const MESSAGE_DELETE: Self = _
Message deleted in a channel.
sourcepub const MESSAGE_DELETE_BULK: Self = _
pub const MESSAGE_DELETE_BULK: Self = _
Multiple messages have been deleted in a channel.
sourcepub const MESSAGE_UPDATE: Self = _
pub const MESSAGE_UPDATE: Self = _
Message in a channel has been updated.
sourcepub const PRESENCE_UPDATE: Self = _
pub const PRESENCE_UPDATE: Self = _
User’s presence details are updated.
sourcepub const REACTION_ADD: Self = _
pub const REACTION_ADD: Self = _
Reaction has been added to a message.
sourcepub const REACTION_REMOVE: Self = _
pub const REACTION_REMOVE: Self = _
Reaction has been removed from a message.
sourcepub const REACTION_REMOVE_ALL: Self = _
pub const REACTION_REMOVE_ALL: Self = _
All of the reactions for a message have been removed.
sourcepub const REACTION_REMOVE_EMOJI: Self = _
pub const REACTION_REMOVE_EMOJI: Self = _
All of a given emoji’s reactions for a message have been removed.
sourcepub const ROLE_CREATE: Self = _
pub const ROLE_CREATE: Self = _
Role has been created in a guild.
sourcepub const ROLE_DELETE: Self = _
pub const ROLE_DELETE: Self = _
Role has been deleted in a guild.
sourcepub const ROLE_UPDATE: Self = _
pub const ROLE_UPDATE: Self = _
Role has been updated in a guild.
sourcepub const STAGE_INSTANCE_CREATE: Self = _
pub const STAGE_INSTANCE_CREATE: Self = _
Stage instance was created in a stage channel.
sourcepub const STAGE_INSTANCE_DELETE: Self = _
pub const STAGE_INSTANCE_DELETE: Self = _
Stage instance was deleted in a stage channel.
sourcepub const STAGE_INSTANCE_UPDATE: Self = _
pub const STAGE_INSTANCE_UPDATE: Self = _
Stage instance was updated in a stage channel.
sourcepub const THREAD_CREATE: Self = _
pub const THREAD_CREATE: Self = _
A thread has been created, relevant to the current user, or the current user has been added to a thread.
sourcepub const THREAD_DELETE: Self = _
pub const THREAD_DELETE: Self = _
A thread, relevant to the current user, has been deleted.
sourcepub const THREAD_LIST_SYNC: Self = _
pub const THREAD_LIST_SYNC: Self = _
The current user has gained access to a thread.
sourcepub const THREAD_MEMBERS_UPDATE: Self = _
pub const THREAD_MEMBERS_UPDATE: Self = _
A user has been added to or removed from a thread.
sourcepub const THREAD_MEMBER_UPDATE: Self = _
pub const THREAD_MEMBER_UPDATE: Self = _
The thread member object for the current user has been updated.
sourcepub const THREAD_UPDATE: Self = _
pub const THREAD_UPDATE: Self = _
A thread has been updated.
sourcepub const TYPING_START: Self = _
pub const TYPING_START: Self = _
User has begun typing in a channel.
sourcepub const UNAVAILABLE_GUILD: Self = _
pub const UNAVAILABLE_GUILD: Self = _
Guild is unavailable, potentially due to an outage.
sourcepub const USER_UPDATE: Self = _
pub const USER_UPDATE: Self = _
Current user’s profile has been updated.
sourcepub const VOICE_SERVER_UPDATE: Self = _
pub const VOICE_SERVER_UPDATE: Self = _
Voice server has provided an update with voice session details.
sourcepub const VOICE_STATE_UPDATE: Self = _
pub const VOICE_STATE_UPDATE: Self = _
User’s state in a voice channel has been updated.
sourcepub const WEBHOOKS_UPDATE: Self = _
pub const WEBHOOKS_UPDATE: Self = _
Webhook in a guild has been updated.
sourcepub const AUTO_MODERATION_CONFIGURATION: Self = _
pub const AUTO_MODERATION_CONFIGURATION: Self = _
sourcepub const AUTO_MODERATION_EXECUTION: Self = _
pub const AUTO_MODERATION_EXECUTION: Self = _
sourcepub const DIRECT_MESSAGES: Self = _
pub const DIRECT_MESSAGES: Self = _
sourcepub const DIRECT_MESSAGE_REACTIONS: Self = _
pub const DIRECT_MESSAGE_REACTIONS: Self = _
sourcepub const DIRECT_MESSAGE_TYPING: Self = _
pub const DIRECT_MESSAGE_TYPING: Self = _
sourcepub const GUILDS: Self = _
pub const GUILDS: Self = _
All EventTypeFlags
in Intents::GUILDS
.
sourcepub const GUILD_MODERATION: Self = _
pub const GUILD_MODERATION: Self = _
sourcepub const GUILD_EMOJIS_AND_STICKERS: Self = _
pub const GUILD_EMOJIS_AND_STICKERS: Self = _
sourcepub const GUILD_INTEGRATIONS: Self = _
pub const GUILD_INTEGRATIONS: Self = _
sourcepub const GUILD_INVITES: Self = _
pub const GUILD_INVITES: Self = _
All EventTypeFlags
in Intents::GUILD_INVITES
.
sourcepub const GUILD_MEMBERS: Self = _
pub const GUILD_MEMBERS: Self = _
All EventTypeFlags
in Intents::GUILD_MEMBERS
.
sourcepub const GUILD_MESSAGES: Self = _
pub const GUILD_MESSAGES: Self = _
sourcepub const GUILD_MESSAGE_REACTIONS: Self = _
pub const GUILD_MESSAGE_REACTIONS: Self = _
sourcepub const GUILD_MESSAGE_TYPING: Self = _
pub const GUILD_MESSAGE_TYPING: Self = _
sourcepub const GUILD_PRESENCES: Self = _
pub const GUILD_PRESENCES: Self = _
sourcepub const GUILD_SCHEDULED_EVENTS: Self = _
pub const GUILD_SCHEDULED_EVENTS: Self = _
sourcepub const GUILD_VOICE_STATES: Self = _
pub const GUILD_VOICE_STATES: Self = _
sourcepub const GUILD_WEBHOOKS: Self = _
pub const GUILD_WEBHOOKS: Self = _
source§impl EventTypeFlags
impl EventTypeFlags
sourcepub const fn bits(&self) -> u128
pub const fn bits(&self) -> u128
Get the underlying bits value.
The returned value is exactly the bits set in this flags value.
sourcepub const fn from_bits(bits: u128) -> Option<Self>
pub const fn from_bits(bits: u128) -> Option<Self>
Convert from a bits value.
This method will return None
if any unknown bits are set.
sourcepub const fn from_bits_truncate(bits: u128) -> Self
pub const fn from_bits_truncate(bits: u128) -> Self
Convert from a bits value, unsetting any unknown bits.
sourcepub const fn from_bits_retain(bits: u128) -> Self
pub const fn from_bits_retain(bits: u128) -> Self
Convert from a bits value exactly.
sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
Get a flags value with the bits of a flag with the given name set.
This method will return None
if name
is empty or doesn’t
correspond to any named flag.
sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Whether any set bits in a source flags value are also set in a target flags value.
sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Whether all set bits in a source flags value are also set in a target flags value.
sourcepub fn remove(&mut self, other: Self)
pub fn remove(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
remove
won’t truncate other
, but the !
operator will.
sourcepub fn toggle(&mut self, other: Self)
pub fn toggle(&mut self, other: Self)
The bitwise exclusive-or (^
) of the bits in two flags values.
sourcepub fn set(&mut self, other: Self, value: bool)
pub fn set(&mut self, other: Self, value: bool)
Call insert
when value
is true
or remove
when value
is false
.
sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
The bitwise and (&
) of the bits in two flags values.
sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
The bitwise or (|
) of the bits in two flags values.
sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
The bitwise exclusive-or (^
) of the bits in two flags values.
sourcepub const fn complement(self) -> Self
pub const fn complement(self) -> Self
The bitwise negation (!
) of the bits in a flags value, truncating the result.
source§impl EventTypeFlags
impl EventTypeFlags
sourcepub const fn iter(&self) -> Iter<EventTypeFlags>
pub const fn iter(&self) -> Iter<EventTypeFlags>
Yield a set of contained flags values.
Each yielded flags value will correspond to a defined named flag. Any unknown bits will be yielded together as a final flags value.
sourcepub const fn iter_names(&self) -> IterNames<EventTypeFlags>
pub const fn iter_names(&self) -> IterNames<EventTypeFlags>
Yield a set of contained named flags values.
This method is like iter
, except only yields bits in contained named flags.
Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
Trait Implementations§
source§impl Binary for EventTypeFlags
impl Binary for EventTypeFlags
source§impl BitAnd for EventTypeFlags
impl BitAnd for EventTypeFlags
source§impl BitAndAssign for EventTypeFlags
impl BitAndAssign for EventTypeFlags
source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
The bitwise and (&
) of the bits in two flags values.
source§impl BitOr for EventTypeFlags
impl BitOr for EventTypeFlags
source§fn bitor(self, other: EventTypeFlags) -> Self
fn bitor(self, other: EventTypeFlags) -> Self
The bitwise or (|
) of the bits in two flags values.
§type Output = EventTypeFlags
type Output = EventTypeFlags
|
operator.source§impl BitOrAssign for EventTypeFlags
impl BitOrAssign for EventTypeFlags
source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
The bitwise or (|
) of the bits in two flags values.
source§impl BitXor for EventTypeFlags
impl BitXor for EventTypeFlags
source§impl BitXorAssign for EventTypeFlags
impl BitXorAssign for EventTypeFlags
source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
The bitwise exclusive-or (^
) of the bits in two flags values.
source§impl Clone for EventTypeFlags
impl Clone for EventTypeFlags
source§fn clone(&self) -> EventTypeFlags
fn clone(&self) -> EventTypeFlags
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for EventTypeFlags
impl Debug for EventTypeFlags
source§impl Extend<EventTypeFlags> for EventTypeFlags
impl Extend<EventTypeFlags> for EventTypeFlags
source§fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
The bitwise or (|
) of the bits in each flags value.
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Flags for EventTypeFlags
impl Flags for EventTypeFlags
source§const FLAGS: &'static [Flag<EventTypeFlags>] = _
const FLAGS: &'static [Flag<EventTypeFlags>] = _
source§fn from_bits_retain(bits: u128) -> EventTypeFlags
fn from_bits_retain(bits: u128) -> EventTypeFlags
§fn from_bits_truncate(bits: Self::Bits) -> Self
fn from_bits_truncate(bits: Self::Bits) -> Self
§fn from_name(name: &str) -> Option<Self>
fn from_name(name: &str) -> Option<Self>
§fn iter_names(&self) -> IterNames<Self>
fn iter_names(&self) -> IterNames<Self>
§fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
§fn contains(&self, other: Self) -> boolwhere
Self: Sized,
fn contains(&self, other: Self) -> boolwhere
Self: Sized,
§fn insert(&mut self, other: Self)where
Self: Sized,
fn insert(&mut self, other: Self)where
Self: Sized,
|
) of the bits in two flags values.§fn remove(&mut self, other: Self)where
Self: Sized,
fn remove(&mut self, other: Self)where
Self: Sized,
&!
). Read more§fn toggle(&mut self, other: Self)where
Self: Sized,
fn toggle(&mut self, other: Self)where
Self: Sized,
^
) of the bits in two flags values.§fn set(&mut self, other: Self, value: bool)where
Self: Sized,
fn set(&mut self, other: Self, value: bool)where
Self: Sized,
Flags::insert
] when value
is true
or [Flags::remove
] when value
is false
.§fn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
&
) of the bits in two flags values.§fn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
&!
). Read more§fn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
^
) of the bits in two flags values.§fn complement(self) -> Self
fn complement(self) -> Self
!
) of the bits in a flags value, truncating the result.source§impl From<EventType> for EventTypeFlags
impl From<EventType> for EventTypeFlags
source§impl FromIterator<EventTypeFlags> for EventTypeFlags
impl FromIterator<EventTypeFlags> for EventTypeFlags
source§fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
The bitwise or (|
) of the bits in each flags value.
source§impl Hash for EventTypeFlags
impl Hash for EventTypeFlags
source§impl IntoIterator for EventTypeFlags
impl IntoIterator for EventTypeFlags
source§impl LowerHex for EventTypeFlags
impl LowerHex for EventTypeFlags
source§impl Not for EventTypeFlags
impl Not for EventTypeFlags
source§impl Octal for EventTypeFlags
impl Octal for EventTypeFlags
source§impl PartialEq for EventTypeFlags
impl PartialEq for EventTypeFlags
source§fn eq(&self, other: &EventTypeFlags) -> bool
fn eq(&self, other: &EventTypeFlags) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PublicFlags for EventTypeFlags
impl PublicFlags for EventTypeFlags
source§impl Sub for EventTypeFlags
impl Sub for EventTypeFlags
source§fn sub(self, other: Self) -> Self
fn sub(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
§type Output = EventTypeFlags
type Output = EventTypeFlags
-
operator.source§impl SubAssign for EventTypeFlags
impl SubAssign for EventTypeFlags
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
source§impl UpperHex for EventTypeFlags
impl UpperHex for EventTypeFlags
impl Copy for EventTypeFlags
impl Eq for EventTypeFlags
impl StructuralPartialEq for EventTypeFlags
Auto Trait Implementations§
impl Freeze for EventTypeFlags
impl RefUnwindSafe for EventTypeFlags
impl Send for EventTypeFlags
impl Sync for EventTypeFlags
impl Unpin for EventTypeFlags
impl UnwindSafe for EventTypeFlags
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.