Skip to content

Commit

Permalink
Merge pull request #26 from swimos/clippy
Browse files Browse the repository at this point in the history
Clippy lint fixes
  • Loading branch information
SirCipher authored May 23, 2024
2 parents ea4e18f + 41ec458 commit 4db7af5
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
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 @@ -231,7 +231,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,

Check failure on line 81 in ratchet_core/src/protocol/frame.rs

View workflow job for this annotation

GitHub Actions / Clippy

the trait bound `protocol::HeaderFlags: std::cmp::Eq` is not satisfied

Check failure on line 81 in ratchet_core/src/protocol/frame.rs

View workflow job for this annotation

GitHub Actions / Check

the trait bound `HeaderFlags: std::cmp::Eq` is not satisfied

Check failure on line 81 in ratchet_core/src/protocol/frame.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

the trait bound `HeaderFlags: std::cmp::Eq` is not satisfied
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 @@ -62,7 +62,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 @@ -131,7 +131,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 @@ -146,7 +146,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 @@ -166,7 +166,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 @@ -193,7 +193,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 @@ -210,14 +210,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 @@ -244,7 +244,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 @@ -264,7 +264,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
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
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

0 comments on commit 4db7af5

Please sign in to comment.