use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian}; use std::io; use mod_ord::ModOrd; #[derive(Debug)] pub struct Header { pub seq: ModOrd, // 4 // pub seq_minor: u16, // 2 pub ack: ModOrd, // 4 // pub ack_minor: u16, // 2 pub seqs_since_del: u16, // 2 // pub seqs_since_del_minor: u16, // 2 } impl Header { pub const LEN: usize = 10; pub fn write_to(&self, mut w: W) -> Result<(), io::Error> { self.seq.write_to(&mut w)?; // w.write_u16::(self.seq_minor)?; self.ack.write_to(&mut w)?; // w.write_u16::(self.ack_minor)?; w.write_u16::(self.seqs_since_del)?; // w.write_u16::(self.seqs_since_del_minor)?; Ok(()) } pub fn read_from(mut r: R) -> Result { Ok(Header { seq: ModOrd::read_from(&mut r)?, // seq_minor: r.read_u16::()?, ack: ModOrd::read_from(&mut r)?, // ack_minor: r.read_u16::()?, seqs_since_del: r.read_u16::()?, // seqs_since_del_minor: r.read_u16::()?, }) } }