mirror of
https://git.mentality.rip/numas13/xash3d-master.git
synced 2025-01-22 04:44:31 +00:00
refactor
This commit is contained in:
parent
ce759fed3d
commit
0d1b06b207
@ -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>()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user