Trait binrw::BinWriterExt
source · pub trait BinWriterExt: Write + Seek + Sized {
// Provided methods
fn write_type<T: BinWrite>(
&mut self,
value: &T,
endian: Endian,
) -> BinResult<()>
where for<'a> T::Args<'a>: Required { ... }
fn write_be<T: BinWrite>(&mut self, value: &T) -> BinResult<()>
where for<'a> T::Args<'a>: Required { ... }
fn write_le<T: BinWrite>(&mut self, value: &T) -> BinResult<()>
where for<'a> T::Args<'a>: Required { ... }
fn write_ne<T: BinWrite>(&mut self, value: &T) -> BinResult<()>
where for<'a> T::Args<'a>: Required { ... }
fn write_type_args<T: BinWrite>(
&mut self,
value: &T,
endian: Endian,
args: T::Args<'_>,
) -> BinResult<()> { ... }
fn write_be_args<T: BinWrite>(
&mut self,
value: &T,
args: T::Args<'_>,
) -> BinResult<()> { ... }
fn write_le_args<T: BinWrite>(
&mut self,
value: &T,
args: T::Args<'_>,
) -> BinResult<()> { ... }
fn write_ne_args<T: BinWrite>(
&mut self,
value: &T,
args: T::Args<'_>,
) -> BinResult<()> { ... }
}
Expand description
Extension methods for writing BinWrite
objects directly to a writer.
§Examples
use binrw::{binwrite, BinWriterExt, io::Cursor, Endian};
#[binwrite]
struct MyStruct(u8, u16, u8);
let mut writer = Cursor::new(Vec::new());
writer.write_be(&MyStruct(1, 0xffff, 2)).unwrap();
writer.write_type(&0x1234_u16, Endian::Little).unwrap();
assert_eq!(writer.into_inner(), [1, 0xff, 0xff, 2, 0x34, 0x12]);
Provided Methods§
sourcefn write_type<T: BinWrite>(
&mut self,
value: &T,
endian: Endian,
) -> BinResult<()>where
for<'a> T::Args<'a>: Required,
fn write_type<T: BinWrite>(
&mut self,
value: &T,
endian: Endian,
) -> BinResult<()>where
for<'a> T::Args<'a>: Required,
sourcefn write_be<T: BinWrite>(&mut self, value: &T) -> BinResult<()>where
for<'a> T::Args<'a>: Required,
fn write_be<T: BinWrite>(&mut self, value: &T) -> BinResult<()>where
for<'a> T::Args<'a>: Required,
sourcefn write_le<T: BinWrite>(&mut self, value: &T) -> BinResult<()>where
for<'a> T::Args<'a>: Required,
fn write_le<T: BinWrite>(&mut self, value: &T) -> BinResult<()>where
for<'a> T::Args<'a>: Required,
sourcefn write_ne<T: BinWrite>(&mut self, value: &T) -> BinResult<()>where
for<'a> T::Args<'a>: Required,
fn write_ne<T: BinWrite>(&mut self, value: &T) -> BinResult<()>where
for<'a> T::Args<'a>: Required,
sourcefn write_type_args<T: BinWrite>(
&mut self,
value: &T,
endian: Endian,
args: T::Args<'_>,
) -> BinResult<()>
fn write_type_args<T: BinWrite>( &mut self, value: &T, endian: Endian, args: T::Args<'_>, ) -> BinResult<()>
Object Safety§
This trait is not object safe.