pub trait WriteTo {
// Required method
fn write_to(&self, cowfile: &CowFile, offset: usize) -> Result<()>;
}Expand description
Trait for types that can be serialized into a CowFile at a given offset.
Implement this for user-defined structs to enable
CowFile::write_type.
§Examples
use cowfile::{CowFile, WriteTo, Result};
struct Pair {
a: u32,
b: u32,
}
impl WriteTo for Pair {
fn write_to(&self, pf: &CowFile, offset: usize) -> Result<()> {
pf.write_le::<u32>(offset, self.a)?;
pf.write_le::<u32>(offset + 4, self.b)?;
Ok(())
}
}