use toxcore::binary_io::*;
use nom::be_u8;
#[derive(Debug, PartialEq, Clone)]
pub struct ConnectNotification {
pub connection_id: u8
}
impl FromBytes for ConnectNotification {
named!(from_bytes<ConnectNotification>, do_parse!(
tag!("\x02") >>
connection_id: be_u8 >>
(ConnectNotification { connection_id })
));
}
impl ToBytes for ConnectNotification {
fn to_bytes<'a>(&self, buf: (&'a mut [u8], usize)) -> Result<(&'a mut [u8], usize), GenError> {
do_gen!(buf,
gen_be_u8!(0x02) >>
gen_be_u8!(self.connection_id)
)
}
}
#[cfg(test)]
mod test {
use super::*;
encode_decode_test!(
connect_notification_encode_decode,
ConnectNotification {
connection_id: 17
}
);
}