artiq/artiq/firmware/libproto_artiq/analyzer_proto.rs
whitequark 479cb9a857 firmware: use dedicated error types for every protocol and thread.
Good riddance to io::Error::Unrecognized.
2018-05-15 13:27:23 +00:00

24 lines
637 B
Rust

use io::{Write, ProtoWrite, Error as IoError};
#[derive(Debug)]
pub struct Header {
pub sent_bytes: u32,
pub total_byte_count: u64,
pub overflow_occurred: bool,
pub log_channel: u8,
pub dds_onehot_sel: bool
}
impl Header {
pub fn write_to<W>(&self, writer: &mut W) -> Result<(), IoError<W::WriteError>>
where W: Write + ?Sized
{
writer.write_u32(self.sent_bytes)?;
writer.write_u64(self.total_byte_count)?;
writer.write_u8(self.overflow_occurred as u8)?;
writer.write_u8(self.log_channel)?;
writer.write_u8(self.dds_onehot_sel as u8)?;
Ok(())
}
}