mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
src/net: use to_string from Display trait for OutboundState and P2pState enums
This commit is contained in:
@@ -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",
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user