Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy lint fixes #26

Merged
merged 3 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,28 @@ members = [
"ratchet_deflate",
"ratchet_ext",
"ratchet_fixture"
]
]

[workspace.dependencies]
url = "2.1.1"
http = "1.1.0"
tokio = "1.1.1"
tokio-util = "0.7.11"
tokio-stream = "0.1.4"
futures = "0.3.4"
futures-util = "0.3.4"
derive_more = "0.99.14"
thiserror = "1.0"
bytes = "1.0"
rand = "0.8"
sha-1 = "0.10"
base64 = "0.13"
httparse = "1.4.1"
fnv = "1.0.3"
bitflags = "1.2"
either = "1.5.3"
log = "0.4.14"
flate2 = "1.0"
anyhow = "1.0"
serde_json = "1.0"
tracing-subscriber = "0.3.18"
41 changes: 20 additions & 21 deletions ratchet_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,29 @@ repository = "https://github.com/swimos/ratchet/ratchet_core"

[features]
default = []
split = ["futures", "futures-util"]
split = ["futures"]
fixture = []

[dependencies]
ratchet_ext = { version = "0.4.2", path = "../ratchet_ext" }
url = "2.1.1"
http = "1.1.0"
tokio = { version = "1.1.1", features = ["rt", "net", "io-util"] }
tokio-util = { version = "0.7.11", features = ["codec"] }
futures = { version = "0.3.4", optional = true }
futures-util = { version = "0.3.4", optional = true }
derive_more = "0.99.14"
thiserror = "1.0"
bytes = "1.0"
rand = { version = "0.8", features = ["std", "small_rng", "getrandom"] }
sha-1 = "0.10"
base64 = "0.13"
httparse = "1.4.1"
fnv = "1.0.3"
bitflags = "1.2"
either = "1.5.3"
log = "0.4.14"
url = { workspace = true }
http = { workspace = true }
tokio = { workspace = true, features = ["rt", "net", "io-util"] }
tokio-util = { workspace = true, features = ["codec", "compat"] }
futures = { workspace = true, optional = true }
derive_more = { workspace = true }
thiserror = { workspace = true }
bytes = { workspace = true }
rand = { workspace = true, features = ["std", "small_rng", "getrandom"] }
sha-1 = { workspace = true }
base64 = { workspace = true }
httparse = { workspace = true }
fnv = { workspace = true }
bitflags = { workspace = true }
either = { workspace = true }
log = { workspace = true }

[dev-dependencies]
tokio = { version = "1.1.1", features = ["rt-multi-thread", "macros", "test-util"] }
futures = "0.3.4"
futures-util = "0.3.4"
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "test-util"] }
futures = { workspace = true }
futures-util = { workspace = true }
6 changes: 3 additions & 3 deletions ratchet_core/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl From<InvalidStatusCode> for Error {
}

/// HTTP errors.
#[derive(Error, Debug, PartialEq)]
#[derive(Error, Debug, PartialEq, Eq)]
pub enum HttpError {
/// An invalid HTTP method was received.
#[error("Invalid HTTP method: `{0:?}`")]
Expand Down Expand Up @@ -254,7 +254,7 @@ impl From<InvalidHeaderValue> for Error {
}
}

#[derive(Clone, Copy, Error, Debug, PartialEq)]
#[derive(Clone, Copy, Error, Debug, PartialEq, Eq)]
/// The channel is closed
#[error("The channel is already closed")]
pub enum CloseCause {
Expand All @@ -269,7 +269,7 @@ pub enum CloseCause {
}

/// WebSocket protocol errors.
#[derive(Copy, Clone, Debug, PartialEq, Error)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Error)]
pub enum ProtocolError {
/// Invalid encoding was received.
#[error("Not valid UTF-8 encoding")]
Expand Down
2 changes: 1 addition & 1 deletion ratchet_core/src/framed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use std::convert::TryFrom;
use std::fmt::{Debug, Formatter};
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};

#[derive(Debug, PartialEq)]
#[derive(Debug, Eq, PartialEq)]
pub enum Item {
Binary,
Text,
Expand Down
2 changes: 1 addition & 1 deletion ratchet_core/src/framed/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::iter::FromIterator;

#[tokio::test]
async fn frame_text() {
let bytes = BytesMut::from_iter(&[
let bytes = BytesMut::from_iter([
129, 143, 0, 0, 0, 0, 66, 111, 110, 115, 111, 105, 114, 44, 32, 69, 108, 108, 105, 111, 116,
]);

Expand Down
2 changes: 1 addition & 1 deletion ratchet_core/src/handshake/client/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ where
let path_and_query = uri
.path_and_query()
.map(ToString::to_string)
.unwrap_or("/".to_string());
.unwrap_or_else(|| "/".to_string());

Ok(ValidatedRequest {
version,
Expand Down
2 changes: 1 addition & 1 deletion ratchet_core/src/protocol/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct BorrowedFrameHeader<'l> {
pub mask: &'l Option<u32>,
}

#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct FrameHeader {
pub opcode: OpCode,
pub flags: HeaderFlags,
Expand Down
18 changes: 9 additions & 9 deletions ratchet_core/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl HeaderFlags {
}

/// A received WebSocket frame.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Message {
/// A text message.
///
Expand Down Expand Up @@ -130,7 +130,7 @@ pub enum MessageType {
}

/// A configuration for building a WebSocket.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub struct WebSocketConfig {
/// The maximum payload size that is permitted to be received.
pub max_message_size: usize,
Expand All @@ -145,7 +145,7 @@ impl Default for WebSocketConfig {
}

/// The role of a WebSocket.
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Role {
/// The WebSocket is a client.
Client,
Expand All @@ -165,7 +165,7 @@ impl Role {
}
}

#[derive(Debug, Copy, Clone, Display, PartialEq)]
#[derive(Debug, Copy, Clone, Display, PartialEq, Eq)]
pub enum OpCode {
#[display(fmt = "{}", _0)]
DataCode(DataCode),
Expand All @@ -192,7 +192,7 @@ impl From<OpCode> for u8 {
}
}

#[derive(Debug, Copy, Clone, Display, PartialEq)]
#[derive(Debug, Copy, Clone, Display, PartialEq, Eq)]
pub enum DataCode {
Continuation = 0,
Text = 1,
Expand All @@ -209,14 +209,14 @@ impl From<DataCode> for ratchet_ext::OpCode {
}
}

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

#[derive(Copy, Clone, Debug, Error, PartialEq)]
#[derive(Copy, Clone, Debug, Error, PartialEq, Eq)]
pub enum OpCodeParseErr {
#[error("Reserved OpCode: `{0}`")]
Reserved(u8),
Expand All @@ -243,7 +243,7 @@ impl TryFrom<u8> for OpCode {
}

/// A reason for closing the WebSocket connection.
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CloseReason {
/// The code to close the connection with.
pub code: CloseCode,
Expand All @@ -263,7 +263,7 @@ impl CloseReason {
/// <https://mailarchive.ietf.org/arch/msg/hybi/P_1vbD9uyHl63nbIIbFxKMfSwcM/>
/// <https://tools.ietf.org/id/draft-ietf-hybi-thewebsocketprotocol-09.html>
#[allow(missing_docs)]
#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum CloseCode {
Normal,
GoingAway,
Expand Down
2 changes: 1 addition & 1 deletion ratchet_core/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub struct WebSocket<S, E> {
}

/// Denotes the current state of a WebSocket session.
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum CloseState {
/// The session is active.
NotClosed,
Expand Down
10 changes: 5 additions & 5 deletions ratchet_deflate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ repository = "https://github.com/swimos/ratchet/"

[dependencies]
ratchet_ext = { version = "0.4.2", path = "../ratchet_ext" }
thiserror = "1.0"
http = "1.1.0"
bytes = "1.0"
flate2 = { version = "1.0", default-features = false, features = ["zlib"] }
log = "0.4.14"
thiserror = { workspace = true }
http = { workspace = true }
bytes = { workspace = true }
flate2 = { workspace = true, default-features = false, features = ["zlib"] }
log = { workspace = true }
2 changes: 1 addition & 1 deletion ratchet_deflate/src/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const UNKNOWN_PARAM: &str = "Unknown permessage-deflate parameter";
const DUPLICATE_PARAM: &str = "Duplicate permessage-deflate parameter";
const HEADER_ERR: &str = "Failed to produce header";

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct InitialisedDeflateConfig {
pub server_max_window_bits: WindowBits,
pub client_max_window_bits: WindowBits,
Expand Down
6 changes: 3 additions & 3 deletions ratchet_deflate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl ExtensionProvider for DeflateExtProvider {
}

/// Client or server maximum window bits. Wrapping a `u8` with a value in the range of 8..=15.
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd)]
pub struct WindowBits(u8);

#[allow(missing_docs)]
Expand Down Expand Up @@ -150,7 +150,7 @@ impl WindowBits {
}

/// An error produced by `TryFrom<u8>` on `WindowBits` when the value is not in the range of 8..=15.
#[derive(Error, Copy, Clone, Debug, PartialEq, PartialOrd)]
#[derive(Error, Copy, Clone, Debug, PartialEq, Eq, PartialOrd)]
#[error("Invalid window bits: `{0}`")]
pub struct WindowBitsParseErr(u8);

Expand Down Expand Up @@ -184,7 +184,7 @@ impl From<WindowBits> for u8 {
}

/// A permessage-deflate configuration.
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct DeflateConfig {
/// The client's LZ77 sliding window size. Negotiated during the HTTP upgrade. In client mode,
/// this conforms to RFC 7692 7.1.2.1. In server mode, this conforms to RFC 7692 7.1.2.2. Must
Expand Down
6 changes: 3 additions & 3 deletions ratchet_ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ readme = "README.md"
repository = "https://github.com/swimos/ratchet/"

[dependencies]
http = "1.1.0"
httparse = "1.4.1"
bytes = "1.0"
http = { workspace = true }
httparse = { workspace = true }
bytes = { workspace = true }
4 changes: 2 additions & 2 deletions ratchet_ext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ where
}

/// A data code for a frame.
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpCode {
/// The message is a continuation.
Continuation,
Expand Down Expand Up @@ -163,7 +163,7 @@ impl OpCode {
/// This is passed to both `ExtensionEncoder::encode` and `ExtensionDecoder::decode` when a frame
/// has been received. Changes to the reserved bits on a decode call will be sent to the peer.
/// Any other changes or changes made when decoding will have no effect.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct FrameHeader {
/// Whether this is the final frame.
///
Expand Down
8 changes: 4 additions & 4 deletions ratchet_fixture/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ repository = "https://github.com/swimos/ratchet/"

[dependencies]
ratchet = { package = "ratchet_rs", version = "0.4.2", path = "../ratchet_rs", features = ["split", "deflate", "fixture"] }
tokio = { version = "1.1.1", features = ["io-util"] }
bytes = "1.0"
futures = "0.3.4"
tokio = { workspace = true, features = ["io-util"] }
bytes = { workspace = true }
futures = { workspace = true }

[dev-dependencies]
tokio = { version = "1.1.1", features = ["rt-multi-thread", "macros", "test-util"] }
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "test-util"] }
8 changes: 5 additions & 3 deletions ratchet_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ fixture = ["ratchet_core/fixture"]
ratchet_core = { version = "0.4.2", path = "../ratchet_core" }
ratchet_ext = { version = "0.4.2", path = "../ratchet_ext" }
ratchet_deflate = { version = "0.4.2", path = "../ratchet_deflate", optional = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
log = { workspace = true }

[dev-dependencies]
tokio = { version = "1.1.1", features = ["rt-multi-thread", "macros", "test-util"] }
tokio-stream = { version = "0.1.4", features = ["net"] }
bytes = "1.0"
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "test-util"] }
tokio-stream = { workspace = true, features = ["net"] }
bytes = { workspace = true }

[[example]]
name = "autobahn-client"
Expand Down
Loading