Skip to content

Commit

Permalink
Removes derive_more (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
SirCipher authored Sep 26, 2024
1 parent 36a420b commit 317d373
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ tokio-util = "0.7.4"
tokio-stream = "0.1.11"
futures = "0.3.4"
futures-util = "0.3.4"
derive_more = "0.99.14"
thiserror = "1.0"
bytes = "1.0"
rand = "0.8"
Expand Down
1 change: 0 additions & 1 deletion ratchet_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ tokio = { workspace = true, features = ["rt", "net", "io-util"] }
tokio-util = { workspace = true, features = ["codec", "compat"] }
futures = { workspace = true, optional = true }
futures-util = { workspace = true }
derive_more = { workspace = true }
thiserror = { workspace = true }
bytes = { workspace = true }
rand = { workspace = true, features = ["std", "small_rng", "getrandom"] }
Expand Down
28 changes: 22 additions & 6 deletions ratchet_core/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub use frame::*;
pub use mask::apply_mask;

use bytes::Bytes;
use derive_more::Display;
use std::convert::TryFrom;
use std::fmt::{Display, Formatter};
use thiserror::Error;

bitflags::bitflags! {
Expand Down Expand Up @@ -166,14 +166,18 @@ impl Role {
}
}

#[derive(Debug, Copy, Clone, Display, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpCode {
#[display(fmt = "{}", _0)]
DataCode(DataCode),
#[display(fmt = "{}", _0)]
ControlCode(ControlCode),
}

impl Display for OpCode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

impl OpCode {
pub fn is_data(&self) -> bool {
matches!(self, OpCode::DataCode(_))
Expand All @@ -193,13 +197,19 @@ impl From<OpCode> for u8 {
}
}

#[derive(Debug, Copy, Clone, Display, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum DataCode {
Continuation = 0,
Text = 1,
Binary = 2,
}

impl Display for DataCode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

impl From<DataCode> for ratchet_ext::OpCode {
fn from(e: DataCode) -> Self {
match e {
Expand All @@ -210,13 +220,19 @@ impl From<DataCode> for ratchet_ext::OpCode {
}
}

#[derive(Debug, Copy, Clone, Display, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum ControlCode {
Close = 8,
Ping = 9,
Pong = 10,
}

impl Display for ControlCode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

#[derive(Copy, Clone, Debug, Error, PartialEq, Eq)]
pub enum OpCodeParseErr {
#[error("Reserved OpCode: `{0}`")]
Expand Down

0 comments on commit 317d373

Please sign in to comment.