gameServer2/src/utils.rs
author marmistrz
Sun, 24 Jun 2018 12:09:31 -0400
changeset 13421 d1368c776a4f
parent 13416 cdf69667593b
child 13423 87a6cad20c90
permissions -rw-r--r--
Enable all lints from the rust-2018-idioms suite. Additionally, fix the violation of the bare-trait-objects lint.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12126
4348997e502b Refactor code to add more structure to it
unc0rr
parents: 12125
diff changeset
     1
use mio;
4348997e502b Refactor code to add more structure to it
unc0rr
parents: 12125
diff changeset
     2
12137
193dfdcb0620 - Use logging facilities instead of plain println!
unc0rr
parents: 12126
diff changeset
     3
pub const PROTOCOL_VERSION : u32 = 3;
12126
4348997e502b Refactor code to add more structure to it
unc0rr
parents: 12125
diff changeset
     4
pub const SERVER: mio::Token = mio::Token(1000000000 + 0);
13416
cdf69667593b partial room implementation
alfadur
parents: 12137
diff changeset
     5
cdf69667593b partial room implementation
alfadur
parents: 12137
diff changeset
     6
pub fn is_name_illegal(name: &str ) -> bool{
cdf69667593b partial room implementation
alfadur
parents: 12137
diff changeset
     7
    name.len() > 40 ||
cdf69667593b partial room implementation
alfadur
parents: 12137
diff changeset
     8
        name.trim().is_empty() ||
cdf69667593b partial room implementation
alfadur
parents: 12137
diff changeset
     9
        name.chars().any(|c|
cdf69667593b partial room implementation
alfadur
parents: 12137
diff changeset
    10
            "$()*+?[]^{|}\x7F".contains(c) ||
cdf69667593b partial room implementation
alfadur
parents: 12137
diff changeset
    11
                '\x00' <= c && c <= '\x1F')
cdf69667593b partial room implementation
alfadur
parents: 12137
diff changeset
    12
}