Skip to content

Commit

Permalink
feat: Make FullEvent serializable (serenity-rs#3010)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesycod authored and mkrasnitski committed Dec 8, 2024
1 parent 4e435d2 commit 89b668e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/gateway/client/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ macro_rules! event_handler {

/// This enum stores every possible event that an [`EventHandler`] can receive.
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
#[derive(Clone, Debug, VariantNames, IntoStaticStr, EnumCount)]
#[derive(Clone, Debug, VariantNames, IntoStaticStr, EnumCount, Serialize)]
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
pub enum FullEvent {
$(
Expand Down
4 changes: 2 additions & 2 deletions src/gateway/sharding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ pub struct ShardRunnerInfo {
///
/// This might happen when a shard changes from [`ConnectionStage::Identifying`] to
/// [`ConnectionStage::Connected`].
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize)]
pub struct ShardStageUpdateEvent {
/// The new connection stage.
pub new: ConnectionStage,
Expand All @@ -858,7 +858,7 @@ pub struct ShardStageUpdateEvent {
/// Indicates the current connection stage of a [`Shard`].
///
/// This can be useful for knowing which shards are currently "down"/"up".
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
#[non_exhaustive]
pub enum ConnectionStage {
/// Indicator that the [`Shard`] is normally connected and is not in, e.g., a resume phase.
Expand Down
2 changes: 1 addition & 1 deletion src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl CacheHttp for Http {
/// An method used for ratelimiting special routes.
///
/// This is needed because [`reqwest`]'s [`Method`] enum does not derive Copy.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize)]
pub enum LightMethod {
/// Indicates that a route is for the `DELETE` method only.
Delete,
Expand Down
2 changes: 1 addition & 1 deletion src/http/ratelimiting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use crate::internal::prelude::*;

/// Passed to the [`Ratelimiter::set_ratelimit_callback`] callback. If using Client, that callback
/// is initialized to call the `EventHandler::ratelimit()` method.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize)]
#[non_exhaustive]
pub struct RatelimitInfo {
pub timeout: std::time::Duration,
Expand Down
6 changes: 3 additions & 3 deletions src/model/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ id_u64! {

/// An identifier for a Shard.
///
/// This identifier is special, it simply models internal IDs for type safety,
/// and therefore cannot be [`Serialize`]d or [`Deserialize`]d.
/// This identifier is special, it simply models internal IDs for type safety and therefore cannot
/// be deserialized
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize)]
pub struct ShardId(pub u16);

impl ShardId {
Expand Down

0 comments on commit 89b668e

Please sign in to comment.