This commit is contained in:
Denis Drakhnia 2024-08-25 15:29:18 +03:00
parent ce759fed3d
commit 0d1b06b207

View File

@ -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::{
};
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 {
}
}
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
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>()));