forked from lavina/lavina
30 lines
702 B
Rust
30 lines
702 B
Rust
|
|
use super::*;
|
||
|
|
use std::fmt;
|
||
|
|
use crate::core::player::PlayerId;
|
||
|
|
|
||
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
|
|
pub enum Prefix{
|
||
|
|
empty,
|
||
|
|
}
|
||
|
|
impl fmt::Display for Prefix {
|
||
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||
|
|
match self {
|
||
|
|
Prefix::empty => write!(f, ""),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
|
|
pub struct PrefixedNick {
|
||
|
|
pub prefix: Prefix,
|
||
|
|
pub nick: Str,
|
||
|
|
}
|
||
|
|
impl PrefixedNick {
|
||
|
|
pub fn fromStr(nick: Str) -> Result<PrefixedNick> {
|
||
|
|
Ok(PrefixedNick { prefix: Prefix::empty, nick } )
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn fromPlayerId(id: PlayerId) -> Result<PrefixedNick> {
|
||
|
|
Ok(PrefixedNick { prefix: Prefix::empty, nick: id.into_inner() } )
|
||
|
|
}
|
||
|
|
}
|