Browse Source

protocol: fix build with MSRV

master
Denis Drakhnia 1 week ago
parent
commit
ed4591559f
  1. 8
      master/src/master_server.rs
  2. 2
      protocol/Cargo.toml
  3. 3
      protocol/src/cursor.rs
  4. 7
      protocol/src/filter.rs
  5. 3
      protocol/src/lib.rs
  6. 2
      protocol/src/net/game.rs
  7. 2
      protocol/src/net/master.rs

8
master/src/master_server.rs

@ -146,8 +146,8 @@ impl<T> Entry<T> { @@ -146,8 +146,8 @@ impl<T> Entry<T> {
}
impl Entry<ServerInfo> {
fn matches<Addr: AddrExt>(&self, addr: Addr, region: Region, filter: &Filter) -> bool {
self.region == region && filter.matches(addr.wrap(), &self.value)
fn matches(&self, region: Region, filter: &Filter) -> bool {
self.region == region && filter.matches(&self.value)
}
}
@ -448,9 +448,9 @@ impl<Addr: AddrExt> MasterServer<Addr> { @@ -448,9 +448,9 @@ impl<Addr: AddrExt> MasterServer<Addr> {
self.filtered_servers_nat.clear();
self.servers
.iter()
.filter(|(addr, info)| {
.filter(|(_addr, info)| {
info.is_valid(now, self.timeout.server)
&& info.matches(**addr, p.region, &p.filter)
&& info.matches(p.region, &p.filter)
})
.for_each(|(addr, info)| {
self.filtered_servers.push(*addr);

2
protocol/Cargo.toml

@ -15,7 +15,7 @@ repository = "https://git.mentality.rip/numas13/xash3d-master" @@ -15,7 +15,7 @@ repository = "https://git.mentality.rip/numas13/xash3d-master"
default = ["std", "net"]
std = ["alloc"]
alloc = []
net = []
net = ["std"]
[dependencies]
log = "0.4.18"

3
protocol/src/cursor.rs

@ -49,7 +49,8 @@ impl fmt::Display for CursorError { @@ -49,7 +49,8 @@ impl fmt::Display for CursorError {
}
}
impl core::error::Error for CursorError {}
#[cfg(feature = "std")]
impl std::error::Error for CursorError {}
pub type Result<T, E = CursorError> = core::result::Result<T, E>;

7
protocol/src/filter.rs

@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
//! * Do not have bots
//! * Is not protected by a password
use core::{fmt, net::SocketAddr, str::FromStr};
use core::{fmt, str::FromStr};
use bitflags::bitflags;
@ -203,11 +203,10 @@ impl Filter<'_> { @@ -203,11 +203,10 @@ impl Filter<'_> {
}
/// Returns `true` if a server matches the filter.
pub fn matches<T>(&self, _addr: SocketAddr, info: &ServerInfo<T>) -> bool
pub fn matches<T>(&self, info: &ServerInfo<T>) -> bool
where
T: AsRef<[u8]>,
{
// TODO: match addr
!((info.flags & self.flags_mask) != self.flags
|| self.gamedir.map_or(false, |s| *s != info.gamedir.as_ref())
|| self.map.map_or(false, |s| *s != info.map.as_ref())
@ -498,7 +497,7 @@ mod match_tests { @@ -498,7 +497,7 @@ mod match_tests {
let iter = servers
.iter()
.enumerate()
.filter(|(_, (addr, server))| filter.matches(*addr, &server))
.filter(|(_, (_addr, server))| filter.matches(&server))
.map(|(i, _)| i);
assert_eq!(iter.collect::<Vec<_>>(), [$($expected),*])
);

3
protocol/src/lib.rs

@ -85,7 +85,8 @@ impl fmt::Display for Error { @@ -85,7 +85,8 @@ impl fmt::Display for Error {
}
}
impl core::error::Error for Error {}
#[cfg(feature = "std")]
impl std::error::Error for Error {}
impl From<CursorError> for Error {
fn from(source: CursorError) -> Self {

2
protocol/src/net/game.rs

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
//! Game client packets.
use core::{fmt, net::SocketAddr};
use std::{fmt, net::SocketAddr};
use crate::{
cursor::{Cursor, CursorMut},

2
protocol/src/net/master.rs

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
//! Master server packets.
use core::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
use crate::{
cursor::{Cursor, CursorMut},

Loading…
Cancel
Save