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 GIFT_CODE_UPDATE: Self = _
pub const GIFT_CODE_UPDATE: Self = _
Gift code sent in a channel has been updated.
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 PRESENCES_REPLACE: Self = _
pub const PRESENCES_REPLACE: Self = _
Group of presences are replaced.
This is a placeholder as it can happen for bots but has no real meaning.
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_BANS: Self = _
👎Deprecated since 0.14.3: use the GUILD_MODERATION
intent instead
pub const GUILD_BANS: Self = _
GUILD_MODERATION
intent insteadAll EventTypeFlags
in Intents::GUILD_BANS
.
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 = _
sourcepub const fn from_bits(bits: u128) -> Option<Self>
pub const fn from_bits(bits: u128) -> Option<Self>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
sourcepub const fn from_bits_truncate(bits: u128) -> Self
pub const fn from_bits_truncate(bits: u128) -> Self
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
sourcepub const unsafe fn from_bits_unchecked(bits: u128) -> Self
pub const unsafe fn from_bits_unchecked(bits: u128) -> Self
Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).
Safety
The caller of the bitflags!
macro can chose to allow or
disallow extra bits for their bitflags type.
The caller of from_bits_unchecked()
has to ensure that
all bits correspond to a defined flag or that extra bits
are valid for this bitflags type.
sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true
if there are flags common to both self
and other
.
sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true
if all of the flags in other
are contained within self
.
sourcepub fn set(&mut self, other: Self, value: bool)
pub fn set(&mut self, other: Self, value: bool)
Inserts or removes the specified flags depending on the passed value.
sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection between the flags in self
and
other
.
Specifically, the returned set contains only the flags which are
present in both self
and other
.
This is equivalent to using the &
operator (e.g.
ops::BitAnd
), as in flags & other
.
sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of between the flags in self
and other
.
Specifically, the returned set contains all flags which are
present in either self
or other
, including any which are
present in both (see Self::symmetric_difference
if that
is undesirable).
This is equivalent to using the |
operator (e.g.
ops::BitOr
), as in flags | other
.
sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference between the flags in self
and other
.
Specifically, the returned set contains all flags present in
self
, except for the ones present in other
.
It is also conceptually equivalent to the “bit-clear” operation:
flags & !other
(and this syntax is also supported).
This is equivalent to using the -
operator (e.g.
ops::Sub
), as in flags - other
.
sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference between the flags
in self
and other
.
Specifically, the returned set contains the flags present which
are present in self
or other
, but that are not present in
both. Equivalently, it contains the flags present in exactly
one of the sets self
and other
.
This is equivalent to using the ^
operator (e.g.
ops::BitXor
), as in flags ^ other
.
sourcepub const fn complement(self) -> Self
pub const fn complement(self) -> Self
Returns the complement of this set of flags.
Specifically, the returned set contains all the flags which are
not set in self
, but which are allowed for this type.
Alternatively, it can be thought of as the set difference
between Self::all()
and self
(e.g. Self::all() - self
)
This is equivalent to using the !
operator (e.g.
ops::Not
), as in !flags
.
Trait Implementations§
source§impl Binary for EventTypeFlags
impl Binary for EventTypeFlags
source§impl BitAnd<EventTypeFlags> for EventTypeFlags
impl BitAnd<EventTypeFlags> for EventTypeFlags
source§impl BitAndAssign<EventTypeFlags> for EventTypeFlags
impl BitAndAssign<EventTypeFlags> for EventTypeFlags
source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
Disables all flags disabled in the set.
source§impl BitOr<EventTypeFlags> for EventTypeFlags
impl BitOr<EventTypeFlags> for EventTypeFlags
source§fn bitor(self, other: EventTypeFlags) -> Self
fn bitor(self, other: EventTypeFlags) -> Self
Returns the union of the two sets of flags.
§type Output = EventTypeFlags
type Output = EventTypeFlags
|
operator.source§impl BitOrAssign<EventTypeFlags> for EventTypeFlags
impl BitOrAssign<EventTypeFlags> for EventTypeFlags
source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
Adds the set of flags.
source§impl BitXor<EventTypeFlags> for EventTypeFlags
impl BitXor<EventTypeFlags> for EventTypeFlags
source§impl BitXorAssign<EventTypeFlags> for EventTypeFlags
impl BitXorAssign<EventTypeFlags> for EventTypeFlags
source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
Toggles the set of flags.
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)
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 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
source§impl Hash for EventTypeFlags
impl Hash 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 Ord for EventTypeFlags
impl Ord for EventTypeFlags
source§fn cmp(&self, other: &EventTypeFlags) -> Ordering
fn cmp(&self, other: &EventTypeFlags) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<EventTypeFlags> for EventTypeFlags
impl PartialEq<EventTypeFlags> 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 PartialOrd<EventTypeFlags> for EventTypeFlags
impl PartialOrd<EventTypeFlags> for EventTypeFlags
source§fn partial_cmp(&self, other: &EventTypeFlags) -> Option<Ordering>
fn partial_cmp(&self, other: &EventTypeFlags) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Sub<EventTypeFlags> for EventTypeFlags
impl Sub<EventTypeFlags> for EventTypeFlags
source§impl SubAssign<EventTypeFlags> for EventTypeFlags
impl SubAssign<EventTypeFlags> for EventTypeFlags
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Disables all flags enabled in the set.
source§impl UpperHex for EventTypeFlags
impl UpperHex for EventTypeFlags
impl Copy for EventTypeFlags
impl Eq for EventTypeFlags
impl StructuralEq for EventTypeFlags
impl StructuralPartialEq for EventTypeFlags
Auto Trait Implementations§
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
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.