lavina/src/protos/irc/user.rs

30 lines
702 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)]
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() } )
}
}