use crate::chat::constants::message_codes;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum MessageType {
Ping,
Connect,
JOIN,
Unknown,
}
impl From<u32> for MessageType {
fn from(code: u32) -> Self {
match code {
message_codes::PING => Self::Ping,
message_codes::CONNECT => Self::Connect,
message_codes::JOIN => Self::JOIN,
_ => Self::Unknown,
}
}
}
impl MessageType {
pub fn to_code(&self) -> u32 {
match self {
Self::Ping => message_codes::PING,
Self::Connect => message_codes::CONNECT,
Self::JOIN => message_codes::JOIN,
Self::Unknown => 0, }
}
}
#[derive(Debug)]
pub enum Command {
SendChat(String),
Shutdown,
}