diff --git a/src/connections.rs b/src/connections.rs index eb009e8..f3e1ce1 100644 --- a/src/connections.rs +++ b/src/connections.rs @@ -108,7 +108,7 @@ impl interval { - match conn.state { + match &conn.state { ConnectionState::ReceivingConnection | ConnectionState::Connecting => { match self .udp @@ -140,7 +140,7 @@ impl { - match self.udp.send_to(*addr, Package::::Close(reason)) { + match self.udp.send_to(*addr, Package::::Close(reason.clone())) { Ok(bytes) => { conn.bytes_tx += bytes; conn.last_sent_ping = now; @@ -291,7 +291,9 @@ impl { if (now - conn.last_recv_close) > self.config.disconnect_timeout { - messages.push(PeerMessage::Disconnected(conn.clone(), None, reason)); + messages.push(PeerMessage::Disconnected( + conn.clone(), + None, + reason.clone(), + )); false } else { true @@ -664,7 +670,7 @@ impl Connection { } /// State of the connection -#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] +#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)] pub enum ConnectionState { /// Connection is currently attempting to connect to another peer Connecting, diff --git a/src/package.rs b/src/package.rs index f637841..4d1087f 100644 --- a/src/package.rs +++ b/src/package.rs @@ -11,7 +11,7 @@ pub(crate) enum Package { Messages(Messages), } -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone)] pub enum CloseReason { NotAcceptingConnections, Kicked, @@ -19,7 +19,7 @@ pub enum CloseReason { ShuttingDown, /// Closed because local peer initiated close SelfClosed, - InvalidIdentifier, + InvalidIdentifier(String), } impl std::fmt::Display for CloseReason { @@ -30,7 +30,7 @@ impl std::fmt::Display for CloseReason { CloseReason::Error => write!(f, "Error"), CloseReason::ShuttingDown => write!(f, "Shutting down"), CloseReason::SelfClosed => write!(f, "Closed"), - CloseReason::InvalidIdentifier => write!(f, "Invalid Identifier"), + CloseReason::InvalidIdentifier(_) => write!(f, "Invalid Identifier"), } } }