Browse Source

refactor

ipv6
Denis Drakhnia 4 months ago
parent
commit
0d1b06b207
  1. 10
      master/src/master_server.rs

10
master/src/master_server.rs

@ -9,6 +9,7 @@ use std::{ @@ -9,6 +9,7 @@ use std::{
io,
net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs, UdpSocket},
ops::Deref,
str::FromStr,
sync::atomic::{AtomicBool, Ordering},
time::{Duration, Instant},
};
@ -35,7 +36,7 @@ use crate::{ @@ -35,7 +36,7 @@ use crate::{
};
pub trait AddrExt: Sized + Eq + Hash + Display + Copy + ToSocketAddrs + ServerAddress {
type Ip;
type Ip: Eq + Hash + Display + Copy + FromStr;
fn extract(addr: SocketAddr) -> Result<Self, SocketAddr>;
fn ip(&self) -> &Self::Ip;
@ -261,11 +262,7 @@ impl Master { @@ -261,11 +262,7 @@ impl Master {
}
}
impl<Addr> MasterServer<Addr>
where
Addr: AddrExt,
Addr::Ip: Eq + Hash + Display + Copy + std::str::FromStr,
{
impl<Addr: AddrExt> MasterServer<Addr> {
pub fn new(cfg: Config, addr: Addr) -> Result<Self, Error> {
info!("Listen address: {}", addr);
@ -694,7 +691,6 @@ where @@ -694,7 +691,6 @@ where
fn helper<Addr, F>(args: &[&str], mut op: F)
where
Addr: AddrExt,
Addr::Ip: std::str::FromStr,
F: FnMut(&str, Addr::Ip),
{
let iter = args.iter().map(|i| (i, i.parse::<Addr::Ip>()));

Loading…
Cancel
Save