game/src/net/room.rs#
Source: lib/game/src/net/room.rs
room -- rooms by a code or a link, players by a name, no accounts
RoomCode six characters of an alphabet without look-alikes (no 0 O 1 I L: 31 characters, about
887 million codes); random from the server's generator, parse accepts any case and
ignores spaces and dashes ("k7m-2qx")
room_link a link to a room: the page's address with "#CODE" (the fragment never reaches a server
log); room_from_link takes a code back out of such a link, "?room=CODE", ".../r/CODE"
or a bare code
clean_name a player's name: trimmed, inner runs of white space as one space, no control or
direction-changing characters, 1 to 16 characters; unique_name appends " 2", " 3" ...
when the room has it already (compared without case)
/// the characters of a room code
CODE_ALPHABET: &[u8; 31] = b"ABCDEFGHJKMNPQRSTUVWXYZ23456789"
/// characters a name may have at most
MAX_NAME: usize = 16
struct RoomCode(pub [u8; 6])a room's code (see the module header)
impl RoomCode
fn from_random(mut r: u64) -> RoomCodea code from 64 random bits (the server's generator)fn parse(s: &str) -> Option<RoomCode>a code typed by a person: any case, spaces and dashes ignored; None unless six characters of the alphabet remainfn as_str(&self) -> &strthe six charactersfn valid(&self) -> boolthe code's bytes are all of the alphabet (a code read from the network)fn room_link(base: &str, code: &RoomCode) -> Stringa link to a room:base(the page, such as "https://spiel.example/") with "#CODE"fn room_from_link(link: &str) -> Option<RoomCode>the code of a link (fragment "#CODE", query "room=CODE", a path ending in "/r/CODE") or a bare codefn clean_name(raw: &str) -> Option<String>a player's name as the room shows it (see the module header); None when nothing is leftfn unique_name(name: &str, taken: &[&str]) -> Stringnamemade unique amongtaken(compared ASCII-case-insensitively): " 2", " 3" ... appended, the name shortened to keep MAX_NAME characters