lavina/src/protos/irc/user.rs

32 lines
681 B
Rust
Raw Normal View History

2023-09-15 16:10:15 +00:00
use super::*;
use std::fmt;
use crate::core::player::PlayerId;
#[derive(Clone, Debug, PartialEq, Eq)]
2023-09-15 16:27:13 +00:00
pub enum Prefix {
empty,
2023-09-15 16:10:15 +00:00
}
2023-09-15 16:27:13 +00:00
2023-09-15 16:10:15 +00:00
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,
}
2023-09-15 16:27:13 +00:00
2023-09-15 16:10:15 +00:00
impl PrefixedNick {
2023-09-15 16:17:19 +00:00
pub fn fromStr(nick: Str) -> PrefixedNick {
PrefixedNick { prefix: Prefix::empty, nick }
2023-09-15 16:10:15 +00:00
}
2023-09-15 16:17:19 +00:00
pub fn fromPlayerId(id: PlayerId) -> PrefixedNick {
PrefixedNick { prefix: Prefix::empty, nick: id.into_inner() }
2023-09-15 16:10:15 +00:00
}
}