mod debug_message; mod device_info; mod experimental; mod header; mod hello; mod message_type; mod ping; mod state; pub use debug_message::*; pub use device_info::*; pub use experimental::*; pub use header::*; pub use hello::*; pub use message_type::*; pub use ping::*; pub use state::*; #[derive(Debug, Clone)] pub enum Message { None, DeviceInfo(Box), State(State), Ping(Ping), DebugMessage(DebugMessage), Experimental(Experimental), Hello(Hello), } // helper to read fixed-size chunks pub(super) fn take( bytes: &mut &[u8], ) -> Result<[u8; N], Box> { if bytes.len() < N { return Err("buffer too small".into()); } let (head, tail) = bytes.split_at(N); *bytes = tail; Ok(head.try_into()?) }