webchaussette/server/
message_type.rs

1use crate::frame::frame_types::Opcode;
2
3#[derive(Debug)]
4pub enum Types {
5    String(String),
6    Binary(Vec<u8>),
7    None,
8}
9
10impl Types {
11    pub fn from_opcode(opcode: Opcode, data: Vec<u8>) -> Self {
12        match opcode {
13            Opcode::Text => Self::String(String::from_utf8_lossy(&data).to_string()),
14            Opcode::Binary => Self::Binary(data),
15
16            // TODO
17            _ => {
18                unimplemented!()
19            }
20        }
21    }
22}