diff options
Diffstat (limited to 'src/proto.rs')
-rw-r--r-- | src/proto.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/proto.rs b/src/proto.rs index fe3d576..630e3e8 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -1,4 +1,4 @@ -use std::mem; +use std::{mem, fmt}; use std::time::Duration; use super::*; @@ -69,6 +69,21 @@ impl Command { } } +impl fmt::Debug for Command { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(f, "Command::")?; + match *self { + Command::KeepAlive => write!(f, "KeepAlive"), + Command::Ping{data} => write!(f, "Ping {{ data: {:?} }}", &data), + Command::Quit => write!(f, "Quit"), + Command::Play{sec, usec, freq, amp, voice} => write!(f, "Play {{ sec: {:?}, usec: {:?}, freq: {:?}, amp: {:?}, voice: {:?} }}", sec, usec, freq, amp, voice), + Command::Caps{voices, tp, ident} => write!(f, "Caps {{ voices: {:?}, tp: {:?}, ident: {:?} }}", voices, &tp, &ident), + Command::PCM{samples} => write!(f, "PCM {{ samples: {:?} }}", &samples), + Command::Unknown{data} => write!(f, "Unknown {{ data: {:?} }}", &data as &[u8]), + } + } +} + impl<'a> From<&'a [u8; Command::SIZE]> for Command { fn from(packet: &'a [u8; Command::SIZE]) -> Command { let mut fields_u32: [u32; Command::SIZE / 4] = unsafe { mem::uninitialized() }; |