diff --git a/src/net/p2p.rs b/src/net/p2p.rs index 3c91de58e..a8a2329ed 100644 --- a/src/net/p2p.rs +++ b/src/net/p2p.rs @@ -1,13 +1,15 @@ -use async_executor::Executor; use async_std::sync::Mutex; -use log::debug; -use serde_json::json; use std::{ collections::{HashMap, HashSet}, + fmt, net::SocketAddr, sync::Arc, }; +use async_executor::Executor; +use log::debug; +use serde_json::json; + use crate::{ error::{Error, Result}, net::{ @@ -37,14 +39,18 @@ enum P2pState { Run, } -impl P2pState { - fn to_string(&self) -> String { - match self { - Self::Open => "open".to_string(), - Self::Start => "start".to_string(), - Self::Started => "started".to_string(), - Self::Run => "run".to_string(), - } +impl fmt::Display for P2pState { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "{}", + match self { + Self::Open => "open", + Self::Start => "start", + Self::Started => "started", + Self::Run => "run", + } + ) } } diff --git a/src/net/session/outbound_session.rs b/src/net/session/outbound_session.rs index 0d11da9b0..bd8c3751c 100644 --- a/src/net/session/outbound_session.rs +++ b/src/net/session/outbound_session.rs @@ -1,13 +1,15 @@ -use async_executor::Executor; use async_std::{sync::Mutex, task::yield_now}; -use async_trait::async_trait; -use log::{error, info}; -use serde_json::json; use std::{ + fmt, net::SocketAddr, sync::{Arc, Weak}, }; +use async_executor::Executor; +use async_trait::async_trait; +use log::{error, info}; +use serde_json::json; + use crate::{ error::{Error, Result}, net::{ @@ -24,13 +26,17 @@ enum OutboundState { Connected, } -impl OutboundState { - fn to_string(&self) -> String { - match self { - Self::Open => "open".to_string(), - Self::Pending => "pending".to_string(), - Self::Connected => "connected".to_string(), - } +impl fmt::Display for OutboundState { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "{}", + match self { + Self::Open => "open", + Self::Pending => "pending", + Self::Connected => "connected", + } + ) } }