pub trait BufMut {
Show 312 methods
// Required methods
fn mutable(&self) -> usize;
fn truncate_mut(&mut self, new_len: usize);
fn buffer_mut(&mut self) -> &mut [u8] ⓘ;
fn advance_mut(&mut self, cnt: usize);
// Provided methods
fn has_mutable(&self) -> bool { ... }
fn buffer_mut_from(&mut self, offset: usize) -> &mut [u8] ⓘ { ... }
fn buffer_mut_from_checked(&mut self, offset: usize) -> Option<&mut [u8]> { ... }
fn try_advance_mut(&mut self, cnt: usize) -> Result<(), TryAdvanceError> { ... }
fn fill(&mut self, value: u8) { ... }
fn prefix_mut(&mut self, len: usize) -> &mut [u8] ⓘ { ... }
fn prefix_mut_checked(&mut self, len: usize) -> Option<&mut [u8]> { ... }
fn suffix_mut(&mut self, len: usize) -> &mut [u8] ⓘ { ... }
fn suffix_mut_checked(&mut self, len: usize) -> Option<&mut [u8]> { ... }
fn split_at_mut(&mut self, mid: usize) -> (&mut [u8], &mut [u8]) { ... }
fn split_at_mut_checked(
&mut self,
mid: usize,
) -> Option<(&mut [u8], &mut [u8])> { ... }
fn write_slice(&mut self, slice: &[u8]) -> usize { ... }
fn write_slice_checked(&mut self, slice: &[u8]) -> Option<usize> { ... }
fn try_write_slice(&mut self, slice: &[u8]) -> Result<usize, TryWriteError> { ... }
fn write_u16_le(&mut self, value: u16) -> usize { ... }
fn write_u16_le_checked(&mut self, value: u16) -> Option<usize> { ... }
fn try_write_u16_le(&mut self, value: u16) -> Result<usize, TryWriteError> { ... }
fn write_u16_be(&mut self, value: u16) -> usize { ... }
fn write_u16_be_checked(&mut self, value: u16) -> Option<usize> { ... }
fn try_write_u16_be(&mut self, value: u16) -> Result<usize, TryWriteError> { ... }
fn write_u16_ne(&mut self, value: u16) -> usize { ... }
fn write_u16_ne_checked(&mut self, value: u16) -> Option<usize> { ... }
fn try_write_u16_ne(&mut self, value: u16) -> Result<usize, TryWriteError> { ... }
fn write_u32_le(&mut self, value: u32) -> usize { ... }
fn write_u32_le_checked(&mut self, value: u32) -> Option<usize> { ... }
fn try_write_u32_le(&mut self, value: u32) -> Result<usize, TryWriteError> { ... }
fn write_u32_be(&mut self, value: u32) -> usize { ... }
fn write_u32_be_checked(&mut self, value: u32) -> Option<usize> { ... }
fn try_write_u32_be(&mut self, value: u32) -> Result<usize, TryWriteError> { ... }
fn write_u32_ne(&mut self, value: u32) -> usize { ... }
fn write_u32_ne_checked(&mut self, value: u32) -> Option<usize> { ... }
fn try_write_u32_ne(&mut self, value: u32) -> Result<usize, TryWriteError> { ... }
fn write_u64_le(&mut self, value: u64) -> usize { ... }
fn write_u64_le_checked(&mut self, value: u64) -> Option<usize> { ... }
fn try_write_u64_le(&mut self, value: u64) -> Result<usize, TryWriteError> { ... }
fn write_u64_be(&mut self, value: u64) -> usize { ... }
fn write_u64_be_checked(&mut self, value: u64) -> Option<usize> { ... }
fn try_write_u64_be(&mut self, value: u64) -> Result<usize, TryWriteError> { ... }
fn write_u64_ne(&mut self, value: u64) -> usize { ... }
fn write_u64_ne_checked(&mut self, value: u64) -> Option<usize> { ... }
fn try_write_u64_ne(&mut self, value: u64) -> Result<usize, TryWriteError> { ... }
fn write_u128_le(&mut self, value: u128) -> usize { ... }
fn write_u128_le_checked(&mut self, value: u128) -> Option<usize> { ... }
fn try_write_u128_le(&mut self, value: u128) -> Result<usize, TryWriteError> { ... }
fn write_u128_be(&mut self, value: u128) -> usize { ... }
fn write_u128_be_checked(&mut self, value: u128) -> Option<usize> { ... }
fn try_write_u128_be(&mut self, value: u128) -> Result<usize, TryWriteError> { ... }
fn write_u128_ne(&mut self, value: u128) -> usize { ... }
fn write_u128_ne_checked(&mut self, value: u128) -> Option<usize> { ... }
fn try_write_u128_ne(&mut self, value: u128) -> Result<usize, TryWriteError> { ... }
fn write_i16_le(&mut self, value: i16) -> usize { ... }
fn write_i16_le_checked(&mut self, value: i16) -> Option<usize> { ... }
fn try_write_i16_le(&mut self, value: i16) -> Result<usize, TryWriteError> { ... }
fn write_i16_be(&mut self, value: i16) -> usize { ... }
fn write_i16_be_checked(&mut self, value: i16) -> Option<usize> { ... }
fn try_write_i16_be(&mut self, value: i16) -> Result<usize, TryWriteError> { ... }
fn write_i16_ne(&mut self, value: i16) -> usize { ... }
fn write_i16_ne_checked(&mut self, value: i16) -> Option<usize> { ... }
fn try_write_i16_ne(&mut self, value: i16) -> Result<usize, TryWriteError> { ... }
fn write_i32_le(&mut self, value: i32) -> usize { ... }
fn write_i32_le_checked(&mut self, value: i32) -> Option<usize> { ... }
fn try_write_i32_le(&mut self, value: i32) -> Result<usize, TryWriteError> { ... }
fn write_i32_be(&mut self, value: i32) -> usize { ... }
fn write_i32_be_checked(&mut self, value: i32) -> Option<usize> { ... }
fn try_write_i32_be(&mut self, value: i32) -> Result<usize, TryWriteError> { ... }
fn write_i32_ne(&mut self, value: i32) -> usize { ... }
fn write_i32_ne_checked(&mut self, value: i32) -> Option<usize> { ... }
fn try_write_i32_ne(&mut self, value: i32) -> Result<usize, TryWriteError> { ... }
fn write_i64_le(&mut self, value: i64) -> usize { ... }
fn write_i64_le_checked(&mut self, value: i64) -> Option<usize> { ... }
fn try_write_i64_le(&mut self, value: i64) -> Result<usize, TryWriteError> { ... }
fn write_i64_be(&mut self, value: i64) -> usize { ... }
fn write_i64_be_checked(&mut self, value: i64) -> Option<usize> { ... }
fn try_write_i64_be(&mut self, value: i64) -> Result<usize, TryWriteError> { ... }
fn write_i64_ne(&mut self, value: i64) -> usize { ... }
fn write_i64_ne_checked(&mut self, value: i64) -> Option<usize> { ... }
fn try_write_i64_ne(&mut self, value: i64) -> Result<usize, TryWriteError> { ... }
fn write_i128_le(&mut self, value: i128) -> usize { ... }
fn write_i128_le_checked(&mut self, value: i128) -> Option<usize> { ... }
fn try_write_i128_le(&mut self, value: i128) -> Result<usize, TryWriteError> { ... }
fn write_i128_be(&mut self, value: i128) -> usize { ... }
fn write_i128_be_checked(&mut self, value: i128) -> Option<usize> { ... }
fn try_write_i128_be(&mut self, value: i128) -> Result<usize, TryWriteError> { ... }
fn write_i128_ne(&mut self, value: i128) -> usize { ... }
fn write_i128_ne_checked(&mut self, value: i128) -> Option<usize> { ... }
fn try_write_i128_ne(&mut self, value: i128) -> Result<usize, TryWriteError> { ... }
fn write_f32_le(&mut self, value: f32) -> usize { ... }
fn write_f32_le_checked(&mut self, value: f32) -> Option<usize> { ... }
fn try_write_f32_le(&mut self, value: f32) -> Result<usize, TryWriteError> { ... }
fn write_f32_be(&mut self, value: f32) -> usize { ... }
fn write_f32_be_checked(&mut self, value: f32) -> Option<usize> { ... }
fn try_write_f32_be(&mut self, value: f32) -> Result<usize, TryWriteError> { ... }
fn write_f32_ne(&mut self, value: f32) -> usize { ... }
fn write_f32_ne_checked(&mut self, value: f32) -> Option<usize> { ... }
fn try_write_f32_ne(&mut self, value: f32) -> Result<usize, TryWriteError> { ... }
fn write_f64_le(&mut self, value: f64) -> usize { ... }
fn write_f64_le_checked(&mut self, value: f64) -> Option<usize> { ... }
fn try_write_f64_le(&mut self, value: f64) -> Result<usize, TryWriteError> { ... }
fn write_f64_be(&mut self, value: f64) -> usize { ... }
fn write_f64_be_checked(&mut self, value: f64) -> Option<usize> { ... }
fn try_write_f64_be(&mut self, value: f64) -> Result<usize, TryWriteError> { ... }
fn write_f64_ne(&mut self, value: f64) -> usize { ... }
fn write_f64_ne_checked(&mut self, value: f64) -> Option<usize> { ... }
fn try_write_f64_ne(&mut self, value: f64) -> Result<usize, TryWriteError> { ... }
fn write_u8(&mut self, value: u8) -> usize { ... }
fn write_u8_checked(&mut self, value: u8) -> Option<usize> { ... }
fn write_i8(&mut self, value: i8) -> usize { ... }
fn write_i8_checked(&mut self, value: i8) -> Option<usize> { ... }
fn try_write_u8(&mut self, value: u8) -> Result<usize, TryWriteError> { ... }
fn try_write_i8(&mut self, value: i8) -> Result<usize, TryWriteError> { ... }
fn put_slice(&mut self, slice: &[u8]) -> usize { ... }
fn put_slice_checked(&mut self, slice: &[u8]) -> Option<usize> { ... }
fn try_put_slice(&mut self, slice: &[u8]) -> Result<usize, TryWriteError> { ... }
fn put_slice_at(&mut self, slice: &[u8], offset: usize) -> usize { ... }
fn put_slice_at_checked(
&mut self,
slice: &[u8],
offset: usize,
) -> Option<usize> { ... }
fn try_put_slice_at(
&mut self,
slice: &[u8],
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u16_le_at(&mut self, value: u16, offset: usize) -> usize { ... }
fn put_u16_le_at_checked(
&mut self,
value: u16,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u16_le_at(
&mut self,
value: u16,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u16_be_at(&mut self, value: u16, offset: usize) -> usize { ... }
fn put_u16_be_at_checked(
&mut self,
value: u16,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u16_be_at(
&mut self,
value: u16,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u16_ne_at(&mut self, value: u16, offset: usize) -> usize { ... }
fn put_u16_ne_at_checked(
&mut self,
value: u16,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u16_ne_at(
&mut self,
value: u16,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u16_le(&mut self, value: u16) -> usize { ... }
fn put_u16_le_checked(&mut self, value: u16) -> Option<usize> { ... }
fn try_put_u16_le(&mut self, value: u16) -> Result<usize, TryWriteError> { ... }
fn put_u16_be(&mut self, value: u16) -> usize { ... }
fn put_u16_be_checked(&mut self, value: u16) -> Option<usize> { ... }
fn try_put_u16_be(&mut self, value: u16) -> Result<usize, TryWriteError> { ... }
fn put_u16_ne(&mut self, value: u16) -> usize { ... }
fn put_u16_ne_checked(&mut self, value: u16) -> Option<usize> { ... }
fn try_put_u16_ne(&mut self, value: u16) -> Result<usize, TryWriteError> { ... }
fn put_u32_le_at(&mut self, value: u32, offset: usize) -> usize { ... }
fn put_u32_le_at_checked(
&mut self,
value: u32,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u32_le_at(
&mut self,
value: u32,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u32_be_at(&mut self, value: u32, offset: usize) -> usize { ... }
fn put_u32_be_at_checked(
&mut self,
value: u32,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u32_be_at(
&mut self,
value: u32,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u32_ne_at(&mut self, value: u32, offset: usize) -> usize { ... }
fn put_u32_ne_at_checked(
&mut self,
value: u32,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u32_ne_at(
&mut self,
value: u32,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u32_le(&mut self, value: u32) -> usize { ... }
fn put_u32_le_checked(&mut self, value: u32) -> Option<usize> { ... }
fn try_put_u32_le(&mut self, value: u32) -> Result<usize, TryWriteError> { ... }
fn put_u32_be(&mut self, value: u32) -> usize { ... }
fn put_u32_be_checked(&mut self, value: u32) -> Option<usize> { ... }
fn try_put_u32_be(&mut self, value: u32) -> Result<usize, TryWriteError> { ... }
fn put_u32_ne(&mut self, value: u32) -> usize { ... }
fn put_u32_ne_checked(&mut self, value: u32) -> Option<usize> { ... }
fn try_put_u32_ne(&mut self, value: u32) -> Result<usize, TryWriteError> { ... }
fn put_u64_le_at(&mut self, value: u64, offset: usize) -> usize { ... }
fn put_u64_le_at_checked(
&mut self,
value: u64,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u64_le_at(
&mut self,
value: u64,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u64_be_at(&mut self, value: u64, offset: usize) -> usize { ... }
fn put_u64_be_at_checked(
&mut self,
value: u64,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u64_be_at(
&mut self,
value: u64,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u64_ne_at(&mut self, value: u64, offset: usize) -> usize { ... }
fn put_u64_ne_at_checked(
&mut self,
value: u64,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u64_ne_at(
&mut self,
value: u64,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u64_le(&mut self, value: u64) -> usize { ... }
fn put_u64_le_checked(&mut self, value: u64) -> Option<usize> { ... }
fn try_put_u64_le(&mut self, value: u64) -> Result<usize, TryWriteError> { ... }
fn put_u64_be(&mut self, value: u64) -> usize { ... }
fn put_u64_be_checked(&mut self, value: u64) -> Option<usize> { ... }
fn try_put_u64_be(&mut self, value: u64) -> Result<usize, TryWriteError> { ... }
fn put_u64_ne(&mut self, value: u64) -> usize { ... }
fn put_u64_ne_checked(&mut self, value: u64) -> Option<usize> { ... }
fn try_put_u64_ne(&mut self, value: u64) -> Result<usize, TryWriteError> { ... }
fn put_u128_le_at(&mut self, value: u128, offset: usize) -> usize { ... }
fn put_u128_le_at_checked(
&mut self,
value: u128,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u128_le_at(
&mut self,
value: u128,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u128_be_at(&mut self, value: u128, offset: usize) -> usize { ... }
fn put_u128_be_at_checked(
&mut self,
value: u128,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u128_be_at(
&mut self,
value: u128,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u128_ne_at(&mut self, value: u128, offset: usize) -> usize { ... }
fn put_u128_ne_at_checked(
&mut self,
value: u128,
offset: usize,
) -> Option<usize> { ... }
fn try_put_u128_ne_at(
&mut self,
value: u128,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_u128_le(&mut self, value: u128) -> usize { ... }
fn put_u128_le_checked(&mut self, value: u128) -> Option<usize> { ... }
fn try_put_u128_le(&mut self, value: u128) -> Result<usize, TryWriteError> { ... }
fn put_u128_be(&mut self, value: u128) -> usize { ... }
fn put_u128_be_checked(&mut self, value: u128) -> Option<usize> { ... }
fn try_put_u128_be(&mut self, value: u128) -> Result<usize, TryWriteError> { ... }
fn put_u128_ne(&mut self, value: u128) -> usize { ... }
fn put_u128_ne_checked(&mut self, value: u128) -> Option<usize> { ... }
fn try_put_u128_ne(&mut self, value: u128) -> Result<usize, TryWriteError> { ... }
fn put_i16_le_at(&mut self, value: i16, offset: usize) -> usize { ... }
fn put_i16_le_at_checked(
&mut self,
value: i16,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i16_le_at(
&mut self,
value: i16,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i16_be_at(&mut self, value: i16, offset: usize) -> usize { ... }
fn put_i16_be_at_checked(
&mut self,
value: i16,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i16_be_at(
&mut self,
value: i16,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i16_ne_at(&mut self, value: i16, offset: usize) -> usize { ... }
fn put_i16_ne_at_checked(
&mut self,
value: i16,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i16_ne_at(
&mut self,
value: i16,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i16_le(&mut self, value: i16) -> usize { ... }
fn put_i16_le_checked(&mut self, value: i16) -> Option<usize> { ... }
fn try_put_i16_le(&mut self, value: i16) -> Result<usize, TryWriteError> { ... }
fn put_i16_be(&mut self, value: i16) -> usize { ... }
fn put_i16_be_checked(&mut self, value: i16) -> Option<usize> { ... }
fn try_put_i16_be(&mut self, value: i16) -> Result<usize, TryWriteError> { ... }
fn put_i16_ne(&mut self, value: i16) -> usize { ... }
fn put_i16_ne_checked(&mut self, value: i16) -> Option<usize> { ... }
fn try_put_i16_ne(&mut self, value: i16) -> Result<usize, TryWriteError> { ... }
fn put_i32_le_at(&mut self, value: i32, offset: usize) -> usize { ... }
fn put_i32_le_at_checked(
&mut self,
value: i32,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i32_le_at(
&mut self,
value: i32,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i32_be_at(&mut self, value: i32, offset: usize) -> usize { ... }
fn put_i32_be_at_checked(
&mut self,
value: i32,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i32_be_at(
&mut self,
value: i32,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i32_ne_at(&mut self, value: i32, offset: usize) -> usize { ... }
fn put_i32_ne_at_checked(
&mut self,
value: i32,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i32_ne_at(
&mut self,
value: i32,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i32_le(&mut self, value: i32) -> usize { ... }
fn put_i32_le_checked(&mut self, value: i32) -> Option<usize> { ... }
fn try_put_i32_le(&mut self, value: i32) -> Result<usize, TryWriteError> { ... }
fn put_i32_be(&mut self, value: i32) -> usize { ... }
fn put_i32_be_checked(&mut self, value: i32) -> Option<usize> { ... }
fn try_put_i32_be(&mut self, value: i32) -> Result<usize, TryWriteError> { ... }
fn put_i32_ne(&mut self, value: i32) -> usize { ... }
fn put_i32_ne_checked(&mut self, value: i32) -> Option<usize> { ... }
fn try_put_i32_ne(&mut self, value: i32) -> Result<usize, TryWriteError> { ... }
fn put_i64_le_at(&mut self, value: i64, offset: usize) -> usize { ... }
fn put_i64_le_at_checked(
&mut self,
value: i64,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i64_le_at(
&mut self,
value: i64,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i64_be_at(&mut self, value: i64, offset: usize) -> usize { ... }
fn put_i64_be_at_checked(
&mut self,
value: i64,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i64_be_at(
&mut self,
value: i64,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i64_ne_at(&mut self, value: i64, offset: usize) -> usize { ... }
fn put_i64_ne_at_checked(
&mut self,
value: i64,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i64_ne_at(
&mut self,
value: i64,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i64_le(&mut self, value: i64) -> usize { ... }
fn put_i64_le_checked(&mut self, value: i64) -> Option<usize> { ... }
fn try_put_i64_le(&mut self, value: i64) -> Result<usize, TryWriteError> { ... }
fn put_i64_be(&mut self, value: i64) -> usize { ... }
fn put_i64_be_checked(&mut self, value: i64) -> Option<usize> { ... }
fn try_put_i64_be(&mut self, value: i64) -> Result<usize, TryWriteError> { ... }
fn put_i64_ne(&mut self, value: i64) -> usize { ... }
fn put_i64_ne_checked(&mut self, value: i64) -> Option<usize> { ... }
fn try_put_i64_ne(&mut self, value: i64) -> Result<usize, TryWriteError> { ... }
fn put_i128_le_at(&mut self, value: i128, offset: usize) -> usize { ... }
fn put_i128_le_at_checked(
&mut self,
value: i128,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i128_le_at(
&mut self,
value: i128,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i128_be_at(&mut self, value: i128, offset: usize) -> usize { ... }
fn put_i128_be_at_checked(
&mut self,
value: i128,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i128_be_at(
&mut self,
value: i128,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i128_ne_at(&mut self, value: i128, offset: usize) -> usize { ... }
fn put_i128_ne_at_checked(
&mut self,
value: i128,
offset: usize,
) -> Option<usize> { ... }
fn try_put_i128_ne_at(
&mut self,
value: i128,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_i128_le(&mut self, value: i128) -> usize { ... }
fn put_i128_le_checked(&mut self, value: i128) -> Option<usize> { ... }
fn try_put_i128_le(&mut self, value: i128) -> Result<usize, TryWriteError> { ... }
fn put_i128_be(&mut self, value: i128) -> usize { ... }
fn put_i128_be_checked(&mut self, value: i128) -> Option<usize> { ... }
fn try_put_i128_be(&mut self, value: i128) -> Result<usize, TryWriteError> { ... }
fn put_i128_ne(&mut self, value: i128) -> usize { ... }
fn put_i128_ne_checked(&mut self, value: i128) -> Option<usize> { ... }
fn try_put_i128_ne(&mut self, value: i128) -> Result<usize, TryWriteError> { ... }
fn put_f32_le_at(&mut self, value: f32, offset: usize) -> usize { ... }
fn put_f32_le_at_checked(
&mut self,
value: f32,
offset: usize,
) -> Option<usize> { ... }
fn try_put_f32_le_at(
&mut self,
value: f32,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_f32_be_at(&mut self, value: f32, offset: usize) -> usize { ... }
fn put_f32_be_at_checked(
&mut self,
value: f32,
offset: usize,
) -> Option<usize> { ... }
fn try_put_f32_be_at(
&mut self,
value: f32,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_f32_ne_at(&mut self, value: f32, offset: usize) -> usize { ... }
fn put_f32_ne_at_checked(
&mut self,
value: f32,
offset: usize,
) -> Option<usize> { ... }
fn try_put_f32_ne_at(
&mut self,
value: f32,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_f32_le(&mut self, value: f32) -> usize { ... }
fn put_f32_le_checked(&mut self, value: f32) -> Option<usize> { ... }
fn try_put_f32_le(&mut self, value: f32) -> Result<usize, TryWriteError> { ... }
fn put_f32_be(&mut self, value: f32) -> usize { ... }
fn put_f32_be_checked(&mut self, value: f32) -> Option<usize> { ... }
fn try_put_f32_be(&mut self, value: f32) -> Result<usize, TryWriteError> { ... }
fn put_f32_ne(&mut self, value: f32) -> usize { ... }
fn put_f32_ne_checked(&mut self, value: f32) -> Option<usize> { ... }
fn try_put_f32_ne(&mut self, value: f32) -> Result<usize, TryWriteError> { ... }
fn put_f64_le_at(&mut self, value: f64, offset: usize) -> usize { ... }
fn put_f64_le_at_checked(
&mut self,
value: f64,
offset: usize,
) -> Option<usize> { ... }
fn try_put_f64_le_at(
&mut self,
value: f64,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_f64_be_at(&mut self, value: f64, offset: usize) -> usize { ... }
fn put_f64_be_at_checked(
&mut self,
value: f64,
offset: usize,
) -> Option<usize> { ... }
fn try_put_f64_be_at(
&mut self,
value: f64,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_f64_ne_at(&mut self, value: f64, offset: usize) -> usize { ... }
fn put_f64_ne_at_checked(
&mut self,
value: f64,
offset: usize,
) -> Option<usize> { ... }
fn try_put_f64_ne_at(
&mut self,
value: f64,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn put_f64_le(&mut self, value: f64) -> usize { ... }
fn put_f64_le_checked(&mut self, value: f64) -> Option<usize> { ... }
fn try_put_f64_le(&mut self, value: f64) -> Result<usize, TryWriteError> { ... }
fn put_f64_be(&mut self, value: f64) -> usize { ... }
fn put_f64_be_checked(&mut self, value: f64) -> Option<usize> { ... }
fn try_put_f64_be(&mut self, value: f64) -> Result<usize, TryWriteError> { ... }
fn put_f64_ne(&mut self, value: f64) -> usize { ... }
fn put_f64_ne_checked(&mut self, value: f64) -> Option<usize> { ... }
fn try_put_f64_ne(&mut self, value: f64) -> Result<usize, TryWriteError> { ... }
fn put_u8(&mut self, value: u8) -> usize { ... }
fn put_u8_checked(&mut self, value: u8) -> Option<usize> { ... }
fn put_i8(&mut self, value: i8) -> usize { ... }
fn put_i8_checked(&mut self, value: i8) -> Option<usize> { ... }
fn put_u8_at(&mut self, value: u8, offset: usize) -> usize { ... }
fn put_u8_at_checked(&mut self, value: u8, offset: usize) -> Option<usize> { ... }
fn put_i8_at(&mut self, value: i8, offset: usize) -> usize { ... }
fn put_i8_at_checked(&mut self, value: i8, offset: usize) -> Option<usize> { ... }
fn try_put_u8(&mut self, value: u8) -> Result<usize, TryWriteError> { ... }
fn try_put_i8(&mut self, value: i8) -> Result<usize, TryWriteError> { ... }
fn try_put_u8_at(
&mut self,
value: u8,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
fn try_put_i8_at(
&mut self,
value: i8,
offset: usize,
) -> Result<usize, TryWriteAtError> { ... }
}Expand description
A trait for implementing custom buffers that can store and manipulate byte sequences.
Implementers Notes: Implementations should not have any hidden allocation logic.
This trait provides a comprehensive set of methods for writing data to buffers with different error handling strategies:
- Panicking methods (e.g.,
put_*): Fast operations that panic on insufficient space - Checked methods (e.g.,
*_checked): ReturnOption-Noneon failure,Some(bytes_written)on success - Fallible methods (e.g.,
try_*): ReturnResultwith detailed error information
§Method Categories
- Buffer inspection:
mutable(),has_mutable(),buffer(),buffer_mut() - Buffer manipulation:
resize(),truncate_mut(),fill() - Slice operations:
prefix_mut(),suffix_mut(),split_at_mut() - Writing data:
put_slice(),put_u8(),put_u16_le(), etc. - Writing at offset:
put_slice_at(),put_u8_at(),put_u16_le_at(), etc.
Required Methods§
Sourcefn mutable(&self) -> usize
fn mutable(&self) -> usize
Returns the number of bytes available for writing in the buffer.
For fixed-size buffers like &mut [u8], this returns the total buffer size.
For growable buffers like Vec<u8>, this typically returns the current length.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert_eq!(slice.mutable(), 24);Sourcefn truncate_mut(&mut self, new_len: usize)
fn truncate_mut(&mut self, new_len: usize)
Shortens the buffer to the specified length, keeping the first len bytes.
If len is greater than or equal to the buffer’s current length, this has no effect.
This operation cannot fail and will never panic.
§Examples
use bufkit::BufMut;
let mut buf = [1, 2, 3, 4, 5];
let mut slice = &mut buf[..];
BufMut::truncate_mut(&mut slice, 3);
assert_eq!(slice, [1, 2, 3].as_slice());
// Truncating to a length >= current length has no effect
BufMut::truncate_mut(&mut slice, 10);
assert_eq!(slice, [1, 2, 3].as_slice());Sourcefn buffer_mut(&mut self) -> &mut [u8] ⓘ
fn buffer_mut(&mut self) -> &mut [u8] ⓘ
Returns the entire initialized buffer as a mutable slice.
This provides direct access to all buffer contents for efficient manipulation. The returned slice covers all initialized bytes in the buffer.
§Examples
use bufkit::BufMut;
let mut buf = [1, 2, 3, 4];
let mut slice = &mut buf[..];
let slice = slice.buffer_mut();
slice[0] = 0xFF;
assert_eq!(buf[0], 0xFF);Sourcefn advance_mut(&mut self, cnt: usize)
fn advance_mut(&mut self, cnt: usize)
Advances the internal cursor by the specified number of bytes.
This moves the read position forward, making the advanced bytes no longer available for reading. The operation consumes the bytes without returning them.
§Panics
Panics if cnt > self.mutable().
Use try_advance_mut for non-panicking advancement.
§Examples
use bufkit::BufMut;
let mut data = [1, 2, 3, 4, 5];
let mut buf = &mut data[..];
buf.advance_mut(2);
assert_eq!(buf.mutable(), 3);
assert_eq!(buf.buffer_mut(), &[3, 4, 5]);Provided Methods§
Sourcefn has_mutable(&self) -> bool
fn has_mutable(&self) -> bool
Returns true if the buffer has available space for writing.
This is equivalent to self.mutable() == 0.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(BufMut::has_mutable(&slice));
let mut empty: &mut [u8] = &mut [];
assert!(!BufMut::has_mutable(&empty));Sourcefn buffer_mut_from(&mut self, offset: usize) -> &mut [u8] ⓘ
fn buffer_mut_from(&mut self, offset: usize) -> &mut [u8] ⓘ
Returns a mutable slice of the buffer starting from the specified offset.
This is similar to buffer_mut but starts from the given offset
rather than the current cursor position.
§Panics
Panics if offset > self.remaining().
Use buffer_mut_from_checked for non-panicking access.
§Examples
use bufkit::BufMut;
let mut data = [1u8, 2, 3, 4, 5];
let mut buf = &mut data[..];
let slice = buf.buffer_mut_from(2);
slice[0] = 99; // Modify the buffer
assert_eq!(buf.buffer_mut(), &[1, 2, 99, 4, 5]);Sourcefn buffer_mut_from_checked(&mut self, offset: usize) -> Option<&mut [u8]>
fn buffer_mut_from_checked(&mut self, offset: usize) -> Option<&mut [u8]>
Returns a mutable slice of the buffer starting from the specified offset.
This is the non-panicking version of buffer_mut_from.
Returns Some(slice) if offset <= self.remaining(), otherwise returns None.
§Examples
use bufkit::BufMut;
let mut data = [1u8, 2, 3, 4, 5];
let mut buf = &mut data[..];
if let Some(slice) = buf.buffer_mut_from_checked(2) {
slice[0] = 99;
}
assert_eq!(buf.buffer_mut(), &[1, 2, 99, 4, 5]);
assert!(buf.buffer_mut_from_checked(5).unwrap().is_empty()); // empty buffer
assert!(buf.buffer_mut_from_checked(10).is_none()); // Out of boundsSourcefn try_advance_mut(&mut self, cnt: usize) -> Result<(), TryAdvanceError>
fn try_advance_mut(&mut self, cnt: usize) -> Result<(), TryAdvanceError>
Attempts to advance the internal cursor by the specified number of bytes.
This is the non-panicking version of advance_mut.
Returns Ok(()) if the advancement was successful, or Err(TryAdvanceError)
with details about requested vs available bytes.
§Examples
use bufkit::BufMut;
let mut data = [1, 2, 3, 4, 5];
let mut buf = &mut data[..];
assert!(buf.try_advance_mut(3).is_ok());
assert_eq!(buf.mutable(), 2);
let err = buf.try_advance_mut(5).unwrap_err();
// err contains details about requested vs availableSourcefn fill(&mut self, value: u8)
fn fill(&mut self, value: u8)
Fills the entire buffer with the specified byte value.
This overwrites all bytes in the buffer with value.
§Examples
use bufkit::BufMut;
let mut buf = [1, 2, 3, 4];
let mut slice = &mut buf[..];
slice.fill(0xFF);
assert_eq!(buf, [0xFF, 0xFF, 0xFF, 0xFF]);Sourcefn prefix_mut(&mut self, len: usize) -> &mut [u8] ⓘ
fn prefix_mut(&mut self, len: usize) -> &mut [u8] ⓘ
Returns a mutable slice containing the first len bytes of the buffer.
This provides access to a prefix of the buffer for efficient manipulation of a specific portion without affecting the rest of the buffer.
§Panics
Panics if len > self.mutable().
Use prefix_mut_checked for non-panicking access.
§Examples
use bufkit::BufMut;
let mut buf = [1, 2, 3, 4, 5];
let mut slice = &mut buf[..];
let prefix = slice.prefix_mut(3);
prefix.fill(0xFF);
assert_eq!(buf, [0xFF, 0xFF, 0xFF, 4, 5]);Sourcefn prefix_mut_checked(&mut self, len: usize) -> Option<&mut [u8]>
fn prefix_mut_checked(&mut self, len: usize) -> Option<&mut [u8]>
Returns a mutable slice containing the first len bytes of the buffer.
This is the non-panicking version of prefix_mut.
Returns Some(slice) if len <= self.mutable(), otherwise returns None.
§Examples
use bufkit::BufMut;
let mut buf = [1, 2, 3, 4, 5];
let mut slice = &mut buf[..];
assert_eq!(slice.prefix_mut_checked(3).unwrap(), &[1, 2, 3]);
assert_eq!(slice.prefix_mut_checked(5).unwrap(), &[1, 2, 3, 4, 5]);
assert!(slice.prefix_mut_checked(10).is_none());Sourcefn suffix_mut(&mut self, len: usize) -> &mut [u8] ⓘ
fn suffix_mut(&mut self, len: usize) -> &mut [u8] ⓘ
Returns a mutable slice containing the last len bytes of the buffer.
This provides access to a suffix of the buffer for efficient manipulation of the trailing portion without affecting the rest of the buffer.
§Panics
Panics if len > self.mutable().
Use suffix_mut_checked for non-panicking access.
§Examples
use bufkit::BufMut;
let mut buf = [1, 2, 3, 4, 5];
let mut slice = &mut buf[..];
let suffix = slice.suffix_mut(2);
suffix.fill(0xFF);
assert_eq!(buf, [1, 2, 3, 0xFF, 0xFF]);Sourcefn suffix_mut_checked(&mut self, len: usize) -> Option<&mut [u8]>
fn suffix_mut_checked(&mut self, len: usize) -> Option<&mut [u8]>
Returns a mutable slice containing the last len bytes of the buffer.
This is the non-panicking version of suffix_mut.
Returns Some(slice) if len <= self.mutable(), otherwise returns None.
§Examples
use bufkit::BufMut;
let mut buf = [1, 2, 3, 4, 5];
let mut slice = &mut buf[..];
assert_eq!(slice.suffix_mut_checked(2).unwrap(), &[4, 5]);
assert_eq!(slice.suffix_mut_checked(5).unwrap(), &[1, 2, 3, 4, 5]);
assert!(slice.suffix_mut_checked(10).is_none());Sourcefn split_at_mut(&mut self, mid: usize) -> (&mut [u8], &mut [u8])
fn split_at_mut(&mut self, mid: usize) -> (&mut [u8], &mut [u8])
Divides the buffer into two mutable slices at the given index.
Returns a tuple where the first slice contains indices [0, mid) and
the second slice contains indices [mid, len).
§Panics
Panics if mid > self.mutable().
Use split_at_mut_checked for non-panicking splitting.
§Examples
use bufkit::BufMut;
let mut buf = [1, 2, 3, 4, 5];
let mut slice = &mut buf[..];
let (left, right) = slice.split_at_mut(2);
assert_eq!(left, &[1, 2]);
assert_eq!(right, &[3, 4, 5]);Sourcefn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut [u8], &mut [u8])>
fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut [u8], &mut [u8])>
Divides the buffer into two mutable slices at the given index.
This is the non-panicking version of split_at_mut.
Returns Some((left, right)) if mid <= self.mutable(), otherwise returns None.
§Examples
use bufkit::BufMut;
let mut buf = [1, 2, 3, 4, 5];
let mut slice = &mut buf[..];
assert!(slice.split_at_mut_checked(2).is_some());
assert!(slice.split_at_mut_checked(10).is_none());Sourcefn write_slice(&mut self, slice: &[u8]) -> usize
fn write_slice(&mut self, slice: &[u8]) -> usize
Writes slice of bytes to the beginning of the buffer and advances the internal cursor.
Copies all bytes from slice into the buffer starting at the beginning.
Returns the number of bytes written (always equal to slice.len()).
§Panics
Panics if slice.len() > self.mutable().
Use put_slice_checked or
try_put_slice for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_slice(&[1, 2, 3]);
assert_eq!(written, 3);
assert_eq!(&buf[..3], &[1, 2, 3]);Sourcefn write_slice_checked(&mut self, slice: &[u8]) -> Option<usize>
fn write_slice_checked(&mut self, slice: &[u8]) -> Option<usize>
Tries to write slice of bytes to the beginning of the buffer and advance the internal cursor.
This is the non-panicking version of put_slice.
Returns Some(bytes_written) on success, or None if the buffer is too small.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
assert_eq!(slice.put_slice_checked(&[1, 2, 3]), Some(3));
assert_eq!(slice.put_slice_checked(&[1, 2, 3, 4, 5, 6]), None);Sourcefn try_write_slice(&mut self, slice: &[u8]) -> Result<usize, TryWriteError>
fn try_write_slice(&mut self, slice: &[u8]) -> Result<usize, TryWriteError>
Tries to write slice of bytes to the beginning of the buffer and advance the internal cursor.
This is the non-panicking version of put_slice that
returns detailed error information on failure.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with details about
the attempted write size and available space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
assert!(slice.try_put_slice(&[1, 2, 3]).is_ok());
let err = slice.try_put_slice(&[1, 2, 3, 4, 5, 6]).unwrap_err();
// err contains details about requested vs available spaceSourcefn write_u16_le(&mut self, value: u16) -> usize
fn write_u16_le(&mut self, value: u16) -> usize
Writes u16 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<u16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u16_le(0x1234 as u16);
assert_eq!(written, size_of::<u16>());
assert_eq!(slice.mutable(), 24 - size_of::<u16>());
// Value is written in little-endian format at the beginningSourcefn write_u16_le_checked(&mut self, value: u16) -> Option<usize>
fn write_u16_le_checked(&mut self, value: u16) -> Option<usize>
Tries to write u16 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u16_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u16_le_checked(0x1234 as u16).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u16_le_checked(0x1234 as u16).is_none()); // Not enough spaceSourcefn try_write_u16_le(&mut self, value: u16) -> Result<usize, TryWriteError>
fn try_write_u16_le(&mut self, value: u16) -> Result<usize, TryWriteError>
Tries to write u16 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u16_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u16_le(0x1234 as u16).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u16_le(0x1234 as u16).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u16_be(&mut self, value: u16) -> usize
fn write_u16_be(&mut self, value: u16) -> usize
Writes u16 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<u16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u16_be(0x1234 as u16);
assert_eq!(written, size_of::<u16>());
assert_eq!(slice.mutable(), 24 - size_of::<u16>());
// Value is written in big-endian format at the beginningSourcefn write_u16_be_checked(&mut self, value: u16) -> Option<usize>
fn write_u16_be_checked(&mut self, value: u16) -> Option<usize>
Tries to write u16 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u16_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u16_be_checked(0x1234 as u16).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u16_be_checked(0x1234 as u16).is_none()); // Not enough spaceSourcefn try_write_u16_be(&mut self, value: u16) -> Result<usize, TryWriteError>
fn try_write_u16_be(&mut self, value: u16) -> Result<usize, TryWriteError>
Tries to write u16 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u16_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u16_be(0x1234 as u16).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u16_be(0x1234 as u16).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u16_ne(&mut self, value: u16) -> usize
fn write_u16_ne(&mut self, value: u16) -> usize
Writes u16 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u16_ne(0x1234 as u16);
assert_eq!(written, size_of::<u16>());
assert_eq!(slice.mutable(), 24 - size_of::<u16>());
// Value is written in native-endian format at the beginningSourcefn write_u16_ne_checked(&mut self, value: u16) -> Option<usize>
fn write_u16_ne_checked(&mut self, value: u16) -> Option<usize>
Tries to write u16 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_u16_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u16_ne_checked(0x1234 as u16).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u16_ne_checked(0x1234 as u16).is_none()); // Not enough spaceSourcefn try_write_u16_ne(&mut self, value: u16) -> Result<usize, TryWriteError>
fn try_write_u16_ne(&mut self, value: u16) -> Result<usize, TryWriteError>
Tries to write u16 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_u16_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u16_ne(0x1234 as u16).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u16_ne(0x1234 as u16).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u32_le(&mut self, value: u32) -> usize
fn write_u32_le(&mut self, value: u32) -> usize
Writes u32 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<u32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u32_le(0x1234 as u32);
assert_eq!(written, size_of::<u32>());
assert_eq!(slice.mutable(), 24 - size_of::<u32>());
// Value is written in little-endian format at the beginningSourcefn write_u32_le_checked(&mut self, value: u32) -> Option<usize>
fn write_u32_le_checked(&mut self, value: u32) -> Option<usize>
Tries to write u32 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u32_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u32_le_checked(0x1234 as u32).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u32_le_checked(0x1234 as u32).is_none()); // Not enough spaceSourcefn try_write_u32_le(&mut self, value: u32) -> Result<usize, TryWriteError>
fn try_write_u32_le(&mut self, value: u32) -> Result<usize, TryWriteError>
Tries to write u32 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u32_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u32_le(0x1234 as u32).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u32_le(0x1234 as u32).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u32_be(&mut self, value: u32) -> usize
fn write_u32_be(&mut self, value: u32) -> usize
Writes u32 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<u32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u32_be(0x1234 as u32);
assert_eq!(written, size_of::<u32>());
assert_eq!(slice.mutable(), 24 - size_of::<u32>());
// Value is written in big-endian format at the beginningSourcefn write_u32_be_checked(&mut self, value: u32) -> Option<usize>
fn write_u32_be_checked(&mut self, value: u32) -> Option<usize>
Tries to write u32 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u32_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u32_be_checked(0x1234 as u32).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u32_be_checked(0x1234 as u32).is_none()); // Not enough spaceSourcefn try_write_u32_be(&mut self, value: u32) -> Result<usize, TryWriteError>
fn try_write_u32_be(&mut self, value: u32) -> Result<usize, TryWriteError>
Tries to write u32 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u32_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u32_be(0x1234 as u32).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u32_be(0x1234 as u32).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u32_ne(&mut self, value: u32) -> usize
fn write_u32_ne(&mut self, value: u32) -> usize
Writes u32 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u32_ne(0x1234 as u32);
assert_eq!(written, size_of::<u32>());
assert_eq!(slice.mutable(), 24 - size_of::<u32>());
// Value is written in native-endian format at the beginningSourcefn write_u32_ne_checked(&mut self, value: u32) -> Option<usize>
fn write_u32_ne_checked(&mut self, value: u32) -> Option<usize>
Tries to write u32 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_u32_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u32_ne_checked(0x1234 as u32).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u32_ne_checked(0x1234 as u32).is_none()); // Not enough spaceSourcefn try_write_u32_ne(&mut self, value: u32) -> Result<usize, TryWriteError>
fn try_write_u32_ne(&mut self, value: u32) -> Result<usize, TryWriteError>
Tries to write u32 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_u32_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u32_ne(0x1234 as u32).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u32_ne(0x1234 as u32).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u64_le(&mut self, value: u64) -> usize
fn write_u64_le(&mut self, value: u64) -> usize
Writes u64 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<u64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u64_le(0x1234 as u64);
assert_eq!(written, size_of::<u64>());
assert_eq!(slice.mutable(), 24 - size_of::<u64>());
// Value is written in little-endian format at the beginningSourcefn write_u64_le_checked(&mut self, value: u64) -> Option<usize>
fn write_u64_le_checked(&mut self, value: u64) -> Option<usize>
Tries to write u64 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u64_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u64_le_checked(0x1234 as u64).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u64_le_checked(0x1234 as u64).is_none()); // Not enough spaceSourcefn try_write_u64_le(&mut self, value: u64) -> Result<usize, TryWriteError>
fn try_write_u64_le(&mut self, value: u64) -> Result<usize, TryWriteError>
Tries to write u64 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u64_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u64_le(0x1234 as u64).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u64_le(0x1234 as u64).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u64_be(&mut self, value: u64) -> usize
fn write_u64_be(&mut self, value: u64) -> usize
Writes u64 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<u64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u64_be(0x1234 as u64);
assert_eq!(written, size_of::<u64>());
assert_eq!(slice.mutable(), 24 - size_of::<u64>());
// Value is written in big-endian format at the beginningSourcefn write_u64_be_checked(&mut self, value: u64) -> Option<usize>
fn write_u64_be_checked(&mut self, value: u64) -> Option<usize>
Tries to write u64 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u64_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u64_be_checked(0x1234 as u64).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u64_be_checked(0x1234 as u64).is_none()); // Not enough spaceSourcefn try_write_u64_be(&mut self, value: u64) -> Result<usize, TryWriteError>
fn try_write_u64_be(&mut self, value: u64) -> Result<usize, TryWriteError>
Tries to write u64 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u64_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u64_be(0x1234 as u64).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u64_be(0x1234 as u64).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u64_ne(&mut self, value: u64) -> usize
fn write_u64_ne(&mut self, value: u64) -> usize
Writes u64 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u64_ne(0x1234 as u64);
assert_eq!(written, size_of::<u64>());
assert_eq!(slice.mutable(), 24 - size_of::<u64>());
// Value is written in native-endian format at the beginningSourcefn write_u64_ne_checked(&mut self, value: u64) -> Option<usize>
fn write_u64_ne_checked(&mut self, value: u64) -> Option<usize>
Tries to write u64 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_u64_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u64_ne_checked(0x1234 as u64).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u64_ne_checked(0x1234 as u64).is_none()); // Not enough spaceSourcefn try_write_u64_ne(&mut self, value: u64) -> Result<usize, TryWriteError>
fn try_write_u64_ne(&mut self, value: u64) -> Result<usize, TryWriteError>
Tries to write u64 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_u64_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u64_ne(0x1234 as u64).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u64_ne(0x1234 as u64).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u128_le(&mut self, value: u128) -> usize
fn write_u128_le(&mut self, value: u128) -> usize
Writes u128 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<u128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u128_le(0x1234 as u128);
assert_eq!(written, size_of::<u128>());
assert_eq!(slice.mutable(), 24 - size_of::<u128>());
// Value is written in little-endian format at the beginningSourcefn write_u128_le_checked(&mut self, value: u128) -> Option<usize>
fn write_u128_le_checked(&mut self, value: u128) -> Option<usize>
Tries to write u128 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u128_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u128_le_checked(0x1234 as u128).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u128_le_checked(0x1234 as u128).is_none()); // Not enough spaceSourcefn try_write_u128_le(&mut self, value: u128) -> Result<usize, TryWriteError>
fn try_write_u128_le(&mut self, value: u128) -> Result<usize, TryWriteError>
Tries to write u128 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u128_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u128_le(0x1234 as u128).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u128_le(0x1234 as u128).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u128_be(&mut self, value: u128) -> usize
fn write_u128_be(&mut self, value: u128) -> usize
Writes u128 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<u128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u128_be(0x1234 as u128);
assert_eq!(written, size_of::<u128>());
assert_eq!(slice.mutable(), 24 - size_of::<u128>());
// Value is written in big-endian format at the beginningSourcefn write_u128_be_checked(&mut self, value: u128) -> Option<usize>
fn write_u128_be_checked(&mut self, value: u128) -> Option<usize>
Tries to write u128 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u128_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u128_be_checked(0x1234 as u128).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u128_be_checked(0x1234 as u128).is_none()); // Not enough spaceSourcefn try_write_u128_be(&mut self, value: u128) -> Result<usize, TryWriteError>
fn try_write_u128_be(&mut self, value: u128) -> Result<usize, TryWriteError>
Tries to write u128 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_u128_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u128_be(0x1234 as u128).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u128_be(0x1234 as u128).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u128_ne(&mut self, value: u128) -> usize
fn write_u128_ne(&mut self, value: u128) -> usize
Writes u128 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_u128_ne(0x1234 as u128);
assert_eq!(written, size_of::<u128>());
assert_eq!(slice.mutable(), 24 - size_of::<u128>());
// Value is written in native-endian format at the beginningSourcefn write_u128_ne_checked(&mut self, value: u128) -> Option<usize>
fn write_u128_ne_checked(&mut self, value: u128) -> Option<usize>
Tries to write u128 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_u128_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_u128_ne_checked(0x1234 as u128).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<u128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_u128_ne_checked(0x1234 as u128).is_none()); // Not enough spaceSourcefn try_write_u128_ne(&mut self, value: u128) -> Result<usize, TryWriteError>
fn try_write_u128_ne(&mut self, value: u128) -> Result<usize, TryWriteError>
Tries to write u128 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_u128_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_u128_ne(0x1234 as u128).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<u128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_u128_ne(0x1234 as u128).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i16_le(&mut self, value: i16) -> usize
fn write_i16_le(&mut self, value: i16) -> usize
Writes i16 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<i16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i16_le(0x1234 as i16);
assert_eq!(written, size_of::<i16>());
assert_eq!(slice.mutable(), 24 - size_of::<i16>());
// Value is written in little-endian format at the beginningSourcefn write_i16_le_checked(&mut self, value: i16) -> Option<usize>
fn write_i16_le_checked(&mut self, value: i16) -> Option<usize>
Tries to write i16 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i16_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i16_le_checked(0x1234 as i16).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i16_le_checked(0x1234 as i16).is_none()); // Not enough spaceSourcefn try_write_i16_le(&mut self, value: i16) -> Result<usize, TryWriteError>
fn try_write_i16_le(&mut self, value: i16) -> Result<usize, TryWriteError>
Tries to write i16 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i16_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i16_le(0x1234 as i16).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i16_le(0x1234 as i16).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i16_be(&mut self, value: i16) -> usize
fn write_i16_be(&mut self, value: i16) -> usize
Writes i16 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<i16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i16_be(0x1234 as i16);
assert_eq!(written, size_of::<i16>());
assert_eq!(slice.mutable(), 24 - size_of::<i16>());
// Value is written in big-endian format at the beginningSourcefn write_i16_be_checked(&mut self, value: i16) -> Option<usize>
fn write_i16_be_checked(&mut self, value: i16) -> Option<usize>
Tries to write i16 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i16_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i16_be_checked(0x1234 as i16).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i16_be_checked(0x1234 as i16).is_none()); // Not enough spaceSourcefn try_write_i16_be(&mut self, value: i16) -> Result<usize, TryWriteError>
fn try_write_i16_be(&mut self, value: i16) -> Result<usize, TryWriteError>
Tries to write i16 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i16_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i16_be(0x1234 as i16).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i16_be(0x1234 as i16).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i16_ne(&mut self, value: i16) -> usize
fn write_i16_ne(&mut self, value: i16) -> usize
Writes i16 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i16_ne(0x1234 as i16);
assert_eq!(written, size_of::<i16>());
assert_eq!(slice.mutable(), 24 - size_of::<i16>());
// Value is written in native-endian format at the beginningSourcefn write_i16_ne_checked(&mut self, value: i16) -> Option<usize>
fn write_i16_ne_checked(&mut self, value: i16) -> Option<usize>
Tries to write i16 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_i16_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i16_ne_checked(0x1234 as i16).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i16_ne_checked(0x1234 as i16).is_none()); // Not enough spaceSourcefn try_write_i16_ne(&mut self, value: i16) -> Result<usize, TryWriteError>
fn try_write_i16_ne(&mut self, value: i16) -> Result<usize, TryWriteError>
Tries to write i16 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_i16_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i16_ne(0x1234 as i16).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i16>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i16_ne(0x1234 as i16).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i32_le(&mut self, value: i32) -> usize
fn write_i32_le(&mut self, value: i32) -> usize
Writes i32 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<i32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i32_le(0x1234 as i32);
assert_eq!(written, size_of::<i32>());
assert_eq!(slice.mutable(), 24 - size_of::<i32>());
// Value is written in little-endian format at the beginningSourcefn write_i32_le_checked(&mut self, value: i32) -> Option<usize>
fn write_i32_le_checked(&mut self, value: i32) -> Option<usize>
Tries to write i32 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i32_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i32_le_checked(0x1234 as i32).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i32_le_checked(0x1234 as i32).is_none()); // Not enough spaceSourcefn try_write_i32_le(&mut self, value: i32) -> Result<usize, TryWriteError>
fn try_write_i32_le(&mut self, value: i32) -> Result<usize, TryWriteError>
Tries to write i32 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i32_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i32_le(0x1234 as i32).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i32_le(0x1234 as i32).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i32_be(&mut self, value: i32) -> usize
fn write_i32_be(&mut self, value: i32) -> usize
Writes i32 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<i32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i32_be(0x1234 as i32);
assert_eq!(written, size_of::<i32>());
assert_eq!(slice.mutable(), 24 - size_of::<i32>());
// Value is written in big-endian format at the beginningSourcefn write_i32_be_checked(&mut self, value: i32) -> Option<usize>
fn write_i32_be_checked(&mut self, value: i32) -> Option<usize>
Tries to write i32 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i32_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i32_be_checked(0x1234 as i32).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i32_be_checked(0x1234 as i32).is_none()); // Not enough spaceSourcefn try_write_i32_be(&mut self, value: i32) -> Result<usize, TryWriteError>
fn try_write_i32_be(&mut self, value: i32) -> Result<usize, TryWriteError>
Tries to write i32 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i32_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i32_be(0x1234 as i32).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i32_be(0x1234 as i32).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i32_ne(&mut self, value: i32) -> usize
fn write_i32_ne(&mut self, value: i32) -> usize
Writes i32 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i32_ne(0x1234 as i32);
assert_eq!(written, size_of::<i32>());
assert_eq!(slice.mutable(), 24 - size_of::<i32>());
// Value is written in native-endian format at the beginningSourcefn write_i32_ne_checked(&mut self, value: i32) -> Option<usize>
fn write_i32_ne_checked(&mut self, value: i32) -> Option<usize>
Tries to write i32 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_i32_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i32_ne_checked(0x1234 as i32).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i32_ne_checked(0x1234 as i32).is_none()); // Not enough spaceSourcefn try_write_i32_ne(&mut self, value: i32) -> Result<usize, TryWriteError>
fn try_write_i32_ne(&mut self, value: i32) -> Result<usize, TryWriteError>
Tries to write i32 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_i32_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i32_ne(0x1234 as i32).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i32_ne(0x1234 as i32).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i64_le(&mut self, value: i64) -> usize
fn write_i64_le(&mut self, value: i64) -> usize
Writes i64 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<i64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i64_le(0x1234 as i64);
assert_eq!(written, size_of::<i64>());
assert_eq!(slice.mutable(), 24 - size_of::<i64>());
// Value is written in little-endian format at the beginningSourcefn write_i64_le_checked(&mut self, value: i64) -> Option<usize>
fn write_i64_le_checked(&mut self, value: i64) -> Option<usize>
Tries to write i64 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i64_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i64_le_checked(0x1234 as i64).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i64_le_checked(0x1234 as i64).is_none()); // Not enough spaceSourcefn try_write_i64_le(&mut self, value: i64) -> Result<usize, TryWriteError>
fn try_write_i64_le(&mut self, value: i64) -> Result<usize, TryWriteError>
Tries to write i64 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i64_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i64_le(0x1234 as i64).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i64_le(0x1234 as i64).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i64_be(&mut self, value: i64) -> usize
fn write_i64_be(&mut self, value: i64) -> usize
Writes i64 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<i64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i64_be(0x1234 as i64);
assert_eq!(written, size_of::<i64>());
assert_eq!(slice.mutable(), 24 - size_of::<i64>());
// Value is written in big-endian format at the beginningSourcefn write_i64_be_checked(&mut self, value: i64) -> Option<usize>
fn write_i64_be_checked(&mut self, value: i64) -> Option<usize>
Tries to write i64 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i64_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i64_be_checked(0x1234 as i64).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i64_be_checked(0x1234 as i64).is_none()); // Not enough spaceSourcefn try_write_i64_be(&mut self, value: i64) -> Result<usize, TryWriteError>
fn try_write_i64_be(&mut self, value: i64) -> Result<usize, TryWriteError>
Tries to write i64 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i64_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i64_be(0x1234 as i64).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i64_be(0x1234 as i64).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i64_ne(&mut self, value: i64) -> usize
fn write_i64_ne(&mut self, value: i64) -> usize
Writes i64 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i64_ne(0x1234 as i64);
assert_eq!(written, size_of::<i64>());
assert_eq!(slice.mutable(), 24 - size_of::<i64>());
// Value is written in native-endian format at the beginningSourcefn write_i64_ne_checked(&mut self, value: i64) -> Option<usize>
fn write_i64_ne_checked(&mut self, value: i64) -> Option<usize>
Tries to write i64 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_i64_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i64_ne_checked(0x1234 as i64).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i64_ne_checked(0x1234 as i64).is_none()); // Not enough spaceSourcefn try_write_i64_ne(&mut self, value: i64) -> Result<usize, TryWriteError>
fn try_write_i64_ne(&mut self, value: i64) -> Result<usize, TryWriteError>
Tries to write i64 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_i64_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i64_ne(0x1234 as i64).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i64_ne(0x1234 as i64).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i128_le(&mut self, value: i128) -> usize
fn write_i128_le(&mut self, value: i128) -> usize
Writes i128 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<i128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i128_le(0x1234 as i128);
assert_eq!(written, size_of::<i128>());
assert_eq!(slice.mutable(), 24 - size_of::<i128>());
// Value is written in little-endian format at the beginningSourcefn write_i128_le_checked(&mut self, value: i128) -> Option<usize>
fn write_i128_le_checked(&mut self, value: i128) -> Option<usize>
Tries to write i128 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i128_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i128_le_checked(0x1234 as i128).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i128_le_checked(0x1234 as i128).is_none()); // Not enough spaceSourcefn try_write_i128_le(&mut self, value: i128) -> Result<usize, TryWriteError>
fn try_write_i128_le(&mut self, value: i128) -> Result<usize, TryWriteError>
Tries to write i128 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i128_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i128_le(0x1234 as i128).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i128_le(0x1234 as i128).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i128_be(&mut self, value: i128) -> usize
fn write_i128_be(&mut self, value: i128) -> usize
Writes i128 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<i128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i128_be(0x1234 as i128);
assert_eq!(written, size_of::<i128>());
assert_eq!(slice.mutable(), 24 - size_of::<i128>());
// Value is written in big-endian format at the beginningSourcefn write_i128_be_checked(&mut self, value: i128) -> Option<usize>
fn write_i128_be_checked(&mut self, value: i128) -> Option<usize>
Tries to write i128 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i128_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i128_be_checked(0x1234 as i128).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i128_be_checked(0x1234 as i128).is_none()); // Not enough spaceSourcefn try_write_i128_be(&mut self, value: i128) -> Result<usize, TryWriteError>
fn try_write_i128_be(&mut self, value: i128) -> Result<usize, TryWriteError>
Tries to write i128 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_i128_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i128_be(0x1234 as i128).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i128_be(0x1234 as i128).unwrap_err();
// err contains information about required vs available spaceSourcefn write_i128_ne(&mut self, value: i128) -> usize
fn write_i128_ne(&mut self, value: i128) -> usize
Writes i128 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_i128_ne(0x1234 as i128);
assert_eq!(written, size_of::<i128>());
assert_eq!(slice.mutable(), 24 - size_of::<i128>());
// Value is written in native-endian format at the beginningSourcefn write_i128_ne_checked(&mut self, value: i128) -> Option<usize>
fn write_i128_ne_checked(&mut self, value: i128) -> Option<usize>
Tries to write i128 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_i128_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_i128_ne_checked(0x1234 as i128).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<i128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_i128_ne_checked(0x1234 as i128).is_none()); // Not enough spaceSourcefn try_write_i128_ne(&mut self, value: i128) -> Result<usize, TryWriteError>
fn try_write_i128_ne(&mut self, value: i128) -> Result<usize, TryWriteError>
Tries to write i128 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_i128_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_i128_ne(0x1234 as i128).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<i128>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_i128_ne(0x1234 as i128).unwrap_err();
// err contains information about required vs available spaceSourcefn write_f32_le(&mut self, value: f32) -> usize
fn write_f32_le(&mut self, value: f32) -> usize
Writes f32 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<f32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_f32_le(0x1234 as f32);
assert_eq!(written, size_of::<f32>());
assert_eq!(slice.mutable(), 24 - size_of::<f32>());
// Value is written in little-endian format at the beginningSourcefn write_f32_le_checked(&mut self, value: f32) -> Option<usize>
fn write_f32_le_checked(&mut self, value: f32) -> Option<usize>
Tries to write f32 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_f32_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_f32_le_checked(0x1234 as f32).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<f32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_f32_le_checked(0x1234 as f32).is_none()); // Not enough spaceSourcefn try_write_f32_le(&mut self, value: f32) -> Result<usize, TryWriteError>
fn try_write_f32_le(&mut self, value: f32) -> Result<usize, TryWriteError>
Tries to write f32 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_f32_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_f32_le(0x1234 as f32).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<f32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_f32_le(0x1234 as f32).unwrap_err();
// err contains information about required vs available spaceSourcefn write_f32_be(&mut self, value: f32) -> usize
fn write_f32_be(&mut self, value: f32) -> usize
Writes f32 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<f32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_f32_be(0x1234 as f32);
assert_eq!(written, size_of::<f32>());
assert_eq!(slice.mutable(), 24 - size_of::<f32>());
// Value is written in big-endian format at the beginningSourcefn write_f32_be_checked(&mut self, value: f32) -> Option<usize>
fn write_f32_be_checked(&mut self, value: f32) -> Option<usize>
Tries to write f32 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_f32_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_f32_be_checked(0x1234 as f32).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<f32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_f32_be_checked(0x1234 as f32).is_none()); // Not enough spaceSourcefn try_write_f32_be(&mut self, value: f32) -> Result<usize, TryWriteError>
fn try_write_f32_be(&mut self, value: f32) -> Result<usize, TryWriteError>
Tries to write f32 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_f32_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_f32_be(0x1234 as f32).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<f32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_f32_be(0x1234 as f32).unwrap_err();
// err contains information about required vs available spaceSourcefn write_f32_ne(&mut self, value: f32) -> usize
fn write_f32_ne(&mut self, value: f32) -> usize
Writes f32 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<f32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_f32_ne(0x1234 as f32);
assert_eq!(written, size_of::<f32>());
assert_eq!(slice.mutable(), 24 - size_of::<f32>());
// Value is written in native-endian format at the beginningSourcefn write_f32_ne_checked(&mut self, value: f32) -> Option<usize>
fn write_f32_ne_checked(&mut self, value: f32) -> Option<usize>
Tries to write f32 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_f32_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_f32_ne_checked(0x1234 as f32).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<f32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_f32_ne_checked(0x1234 as f32).is_none()); // Not enough spaceSourcefn try_write_f32_ne(&mut self, value: f32) -> Result<usize, TryWriteError>
fn try_write_f32_ne(&mut self, value: f32) -> Result<usize, TryWriteError>
Tries to write f32 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_f32_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_f32_ne(0x1234 as f32).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<f32>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_f32_ne(0x1234 as f32).unwrap_err();
// err contains information about required vs available spaceSourcefn write_f64_le(&mut self, value: f64) -> usize
fn write_f64_le(&mut self, value: f64) -> usize
Writes f64 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<f64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_f64_le(0x1234 as f64);
assert_eq!(written, size_of::<f64>());
assert_eq!(slice.mutable(), 24 - size_of::<f64>());
// Value is written in little-endian format at the beginningSourcefn write_f64_le_checked(&mut self, value: f64) -> Option<usize>
fn write_f64_le_checked(&mut self, value: f64) -> Option<usize>
Tries to write f64 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_f64_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_f64_le_checked(0x1234 as f64).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<f64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_f64_le_checked(0x1234 as f64).is_none()); // Not enough spaceSourcefn try_write_f64_le(&mut self, value: f64) -> Result<usize, TryWriteError>
fn try_write_f64_le(&mut self, value: f64) -> Result<usize, TryWriteError>
Tries to write f64 value in little-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_f64_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_f64_le(0x1234 as f64).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<f64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_f64_le(0x1234 as f64).unwrap_err();
// err contains information about required vs available spaceSourcefn write_f64_be(&mut self, value: f64) -> usize
fn write_f64_be(&mut self, value: f64) -> usize
Writes f64 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
Returns the number of bytes written (always size_of::<f64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_f64_be(0x1234 as f64);
assert_eq!(written, size_of::<f64>());
assert_eq!(slice.mutable(), 24 - size_of::<f64>());
// Value is written in big-endian format at the beginningSourcefn write_f64_be_checked(&mut self, value: f64) -> Option<usize>
fn write_f64_be_checked(&mut self, value: f64) -> Option<usize>
Tries to write f64 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_f64_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_f64_be_checked(0x1234 as f64).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<f64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_f64_be_checked(0x1234 as f64).is_none()); // Not enough spaceSourcefn try_write_f64_be(&mut self, value: f64) -> Result<usize, TryWriteError>
fn try_write_f64_be(&mut self, value: f64) -> Result<usize, TryWriteError>
Tries to write f64 value in big-endian byte order to the beginning of the buffer, advancing the internal cursor.
This is the non-panicking version of write_f64_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_f64_be(0x1234 as f64).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<f64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_f64_be(0x1234 as f64).unwrap_err();
// err contains information about required vs available spaceSourcefn write_f64_ne(&mut self, value: f64) -> usize
fn write_f64_ne(&mut self, value: f64) -> usize
Writes f64 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<f64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.write_f64_ne(0x1234 as f64);
assert_eq!(written, size_of::<f64>());
assert_eq!(slice.mutable(), 24 - size_of::<f64>());
// Value is written in native-endian format at the beginningSourcefn write_f64_ne_checked(&mut self, value: f64) -> Option<usize>
fn write_f64_ne_checked(&mut self, value: f64) -> Option<usize>
Tries to write f64 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_f64_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.write_f64_ne_checked(0x1234 as f64).is_some());
assert_eq!(slice.mutable(), 24 - size_of::<f64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.write_f64_ne_checked(0x1234 as f64).is_none()); // Not enough spaceSourcefn try_write_f64_ne(&mut self, value: f64) -> Result<usize, TryWriteError>
fn try_write_f64_ne(&mut self, value: f64) -> Result<usize, TryWriteError>
Tries to write f64 value in native-endian byte order to the beginning of the buffer, advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of write_f64_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_write_f64_ne(0x1234 as f64).is_ok());
assert_eq!(slice.mutable(), 24 - size_of::<f64>());
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_write_f64_ne(0x1234 as f64).unwrap_err();
// err contains information about required vs available spaceSourcefn write_u8(&mut self, value: u8) -> usize
fn write_u8(&mut self, value: u8) -> usize
Writes u8 value to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always 1 for this type).
§Panics
Panics if the buffer has no space available.
Use write_u8_checked for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
let written = slice.write_u8(0xFF);
assert_eq!(written, 1);
assert_eq!(buf[0], 0xFF);Sourcefn write_u8_checked(&mut self, value: u8) -> Option<usize>
fn write_u8_checked(&mut self, value: u8) -> Option<usize>
Tries to write u8 value to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of write_u8.
Returns Some(1) on success, or None if the buffer has no space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 1];
let mut slice = &mut buf[..];
assert_eq!(slice.write_u8_checked(0xFF), Some(1));
let mut empty = &mut [][..];
assert_eq!(empty.write_u8_checked(0xFF), None);Sourcefn write_i8(&mut self, value: i8) -> usize
fn write_i8(&mut self, value: i8) -> usize
Writes i8 value to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always 1 for this type).
§Panics
Panics if the buffer has no space available.
Use write_i8_checked for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
let written = slice.write_i8(-42);
assert_eq!(written, 1);
assert_eq!(buf[0], 214); // -42 as u8 isSourcefn write_i8_checked(&mut self, value: i8) -> Option<usize>
fn write_i8_checked(&mut self, value: i8) -> Option<usize>
Tries to write i8 value to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of write_i8.
Returns Some(1) on success, or None if the buffer has no space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 1];
let mut slice = &mut buf[..];
assert_eq!(slice.write_i8_checked(-42), Some(1));
let mut empty = &mut [][..];
assert_eq!(empty.write_i8_checked(-42), None);Sourcefn try_write_u8(&mut self, value: u8) -> Result<usize, TryWriteError>
fn try_write_u8(&mut self, value: u8) -> Result<usize, TryWriteError>
Tries to write u8 value to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of write_u8 that
returns detailed error information on failure.
Returns Ok(1) on success, or Err(TryWriteError) with details about
the available space if the buffer is full.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
assert!(slice.try_write_u8(0xFF).is_ok());
let mut empty = &mut [][..];
let err = empty.try_write_u8(0xFF).unwrap_err();
// err contains details about requested vs available spaceSourcefn try_write_i8(&mut self, value: i8) -> Result<usize, TryWriteError>
fn try_write_i8(&mut self, value: i8) -> Result<usize, TryWriteError>
Tries to write i8 value to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of write_i8 that
returns detailed error information on failure.
Returns Ok(1) on success, or Err(TryWriteError) with details about
the available space if the buffer is full.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
assert!(slice.try_write_i8(-42).is_ok());
let mut empty = &mut [][..];
let err = empty.try_write_i8(-42).unwrap_err();
// err contains details about requested vs available spaceSourcefn put_slice(&mut self, slice: &[u8]) -> usize
fn put_slice(&mut self, slice: &[u8]) -> usize
Puts slice of bytes to the beginning of the buffer without advancing the internal cursor.
Copies all bytes from slice into the buffer starting at the beginning.
Returns the number of bytes written (always equal to slice.len()).
§Panics
Panics if slice.len() > self.mutable().
Use put_slice_checked or
try_put_slice for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_slice(&[1, 2, 3]);
assert_eq!(written, 3);
assert_eq!(&buf[..3], &[1, 2, 3]);Sourcefn put_slice_checked(&mut self, slice: &[u8]) -> Option<usize>
fn put_slice_checked(&mut self, slice: &[u8]) -> Option<usize>
Tries to put slice of bytes to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_slice.
Returns Some(bytes_written) on success, or None if the buffer is too small.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
assert_eq!(slice.put_slice_checked(&[1, 2, 3]), Some(3));
assert_eq!(slice.put_slice_checked(&[1, 2, 3, 4, 5, 6]), None);Sourcefn try_put_slice(&mut self, slice: &[u8]) -> Result<usize, TryWriteError>
fn try_put_slice(&mut self, slice: &[u8]) -> Result<usize, TryWriteError>
Tries to put slice of bytes to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_slice that
returns detailed error information on failure.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with details about
the attempted write size and available space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
assert!(slice.try_put_slice(&[1, 2, 3]).is_ok());
let err = slice.try_put_slice(&[1, 2, 3, 4, 5, 6]).unwrap_err();
// err contains details about requested vs available spaceSourcefn put_slice_at(&mut self, slice: &[u8], offset: usize) -> usize
fn put_slice_at(&mut self, slice: &[u8], offset: usize) -> usize
Puts slice of bytes to the buffer at the specified offset without advancing the internal cursor.
Copies all bytes from slice into the buffer starting at the given offset.
Returns the number of bytes written (always equal to slice.len()).
§Panics
Panics if offset + slice.len() > self.mutable() or if offset >= self.mutable().
Use put_slice_at_checked or
try_put_slice_at for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_slice_at(&[1, 2, 3], 2);
assert_eq!(written, 3);
assert_eq!(&buf[2..5], &[1, 2, 3]);Sourcefn put_slice_at_checked(&mut self, slice: &[u8], offset: usize) -> Option<usize>
fn put_slice_at_checked(&mut self, slice: &[u8], offset: usize) -> Option<usize>
Tries to put slice of bytes to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_slice_at.
Returns Some(bytes_written) on success, or None if there’s insufficient space
or the offset is out of bounds.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert_eq!(slice.put_slice_at_checked(&[1, 2], 3), Some(2));
assert_eq!(slice.put_slice_at_checked(&[1, 2, 3, 4, 5], 30), None); // Not enough space
assert_eq!(slice.put_slice_at_checked(&[1], 30), None); // Offset out of boundsSourcefn try_put_slice_at(
&mut self,
slice: &[u8],
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_slice_at( &mut self, slice: &[u8], offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put slice of bytes to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_slice_at that
returns detailed error information on failure.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with details about
what went wrong (out of bounds offset, insufficient space, etc.).
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_slice_at(&[1, 2], 3).is_ok());
let err = slice.try_put_slice_at(&[1, 2, 3, 4, 5], 30).unwrap_err();
let err = slice.try_put_slice_at(&[1, 2, 3, 4, 5], 20).unwrap_err();
// err contains detailed information about the failureSourcefn put_u16_le_at(&mut self, value: u16, offset: usize) -> usize
fn put_u16_le_at(&mut self, value: u16, offset: usize) -> usize
Puts a u16 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u16>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u16_le_at(0x1234 as u16, 2);
assert_eq!(written, size_of::<u16>());
// Value is written in little-endian format starting at offset 2Sourcefn put_u16_le_at_checked(&mut self, value: u16, offset: usize) -> Option<usize>
fn put_u16_le_at_checked(&mut self, value: u16, offset: usize) -> Option<usize>
Tries to put u16 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u16_le_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u16_le_at_checked(0x1234 as u16, 2).is_some());
assert!(slice.put_u16_le_at_checked(0x1234 as u16, 30).is_none()); // Out of boundsSourcefn try_put_u16_le_at(
&mut self,
value: u16,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u16_le_at( &mut self, value: u16, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u16 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u16_le_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u16_le_at(0x1234 as u16, 2).is_ok());
let err = slice.try_put_u16_le_at(0x1234 as u16, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u16_be_at(&mut self, value: u16, offset: usize) -> usize
fn put_u16_be_at(&mut self, value: u16, offset: usize) -> usize
Puts u16 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u16>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u16_be_at(0x1234 as u16, 2);
assert_eq!(written, size_of::<u16>());
// Value is written in big-endian format starting at offset 2Sourcefn put_u16_be_at_checked(&mut self, value: u16, offset: usize) -> Option<usize>
fn put_u16_be_at_checked(&mut self, value: u16, offset: usize) -> Option<usize>
Tries to put u16 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u16_be_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u16_be_at_checked(0x1234 as u16, 2).is_some());
assert!(slice.put_u16_be_at_checked(0x1234 as u16, 30).is_none()); // Out of boundsSourcefn try_put_u16_be_at(
&mut self,
value: u16,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u16_be_at( &mut self, value: u16, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u16 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u16_be_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u16_be_at(0x1234 as u16, 2).is_ok());
let err = slice.try_put_u16_be_at(0x1234 as u16, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u16_ne_at(&mut self, value: u16, offset: usize) -> usize
fn put_u16_ne_at(&mut self, value: u16, offset: usize) -> usize
Puts u16 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u16>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u16_ne_at(0x1234 as u16, 2);
assert_eq!(written, size_of::<u16>());
// Value is written in native-endian format starting at offset 2Sourcefn put_u16_ne_at_checked(&mut self, value: u16, offset: usize) -> Option<usize>
fn put_u16_ne_at_checked(&mut self, value: u16, offset: usize) -> Option<usize>
Tries to put u16 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u16_ne_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u16_ne_at_checked(0x1234 as u16, 2).is_some());
assert!(slice.put_u16_ne_at_checked(0x1234 as u16, 30).is_none()); // Out of boundsSourcefn try_put_u16_ne_at(
&mut self,
value: u16,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u16_ne_at( &mut self, value: u16, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u16 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u16_ne_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u16_ne_at(0x1234 as u16, 2).is_ok());
let err = slice.try_put_u16_ne_at(0x1234 as u16, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u16_le(&mut self, value: u16) -> usize
fn put_u16_le(&mut self, value: u16) -> usize
Puts u16 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u16_le(0x1234 as u16);
assert_eq!(written, size_of::<u16>());
// Value is written in little-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u16_le_checked(&mut self, value: u16) -> Option<usize>
fn put_u16_le_checked(&mut self, value: u16) -> Option<usize>
Tries to put u16 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u16_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u16_le_checked(0x1234 as u16).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u16_le_checked(0x1234 as u16).is_none()); // Not enough spaceSourcefn try_put_u16_le(&mut self, value: u16) -> Result<usize, TryWriteError>
fn try_put_u16_le(&mut self, value: u16) -> Result<usize, TryWriteError>
Tries to put u16 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u16_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u16_le(0x1234 as u16).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u16_le(0x1234 as u16).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u16_be(&mut self, value: u16) -> usize
fn put_u16_be(&mut self, value: u16) -> usize
Puts a u16 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u16_be(0x1234 as u16);
assert_eq!(written, size_of::<u16>());
// Value is written in big-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u16_be_checked(&mut self, value: u16) -> Option<usize>
fn put_u16_be_checked(&mut self, value: u16) -> Option<usize>
Tries to put u16 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u16_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u16_be_checked(0x1234 as u16).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u16_be_checked(0x1234 as u16).is_none()); // Not enough spaceSourcefn try_put_u16_be(&mut self, value: u16) -> Result<usize, TryWriteError>
fn try_put_u16_be(&mut self, value: u16) -> Result<usize, TryWriteError>
Tries to put u16 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u16_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u16_be(0x1234 as u16).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u16_be(0x1234 as u16).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u16_ne(&mut self, value: u16) -> usize
fn put_u16_ne(&mut self, value: u16) -> usize
Puts u16 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u16_ne(0x1234 as u16);
assert_eq!(written, size_of::<u16>());
// Value is written in native-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u16_ne_checked(&mut self, value: u16) -> Option<usize>
fn put_u16_ne_checked(&mut self, value: u16) -> Option<usize>
Tries to put u16 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u16_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u16_ne_checked(0x1234 as u16).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u16_ne_checked(0x1234 as u16).is_none()); // Not enough spaceSourcefn try_put_u16_ne(&mut self, value: u16) -> Result<usize, TryWriteError>
fn try_put_u16_ne(&mut self, value: u16) -> Result<usize, TryWriteError>
Tries to put u16 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u16_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u16_ne(0x1234 as u16).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u16_ne(0x1234 as u16).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u32_le_at(&mut self, value: u32, offset: usize) -> usize
fn put_u32_le_at(&mut self, value: u32, offset: usize) -> usize
Puts a u32 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u32>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u32_le_at(0x1234 as u32, 2);
assert_eq!(written, size_of::<u32>());
// Value is written in little-endian format starting at offset 2Sourcefn put_u32_le_at_checked(&mut self, value: u32, offset: usize) -> Option<usize>
fn put_u32_le_at_checked(&mut self, value: u32, offset: usize) -> Option<usize>
Tries to put u32 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u32_le_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u32_le_at_checked(0x1234 as u32, 2).is_some());
assert!(slice.put_u32_le_at_checked(0x1234 as u32, 30).is_none()); // Out of boundsSourcefn try_put_u32_le_at(
&mut self,
value: u32,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u32_le_at( &mut self, value: u32, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u32 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u32_le_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u32_le_at(0x1234 as u32, 2).is_ok());
let err = slice.try_put_u32_le_at(0x1234 as u32, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u32_be_at(&mut self, value: u32, offset: usize) -> usize
fn put_u32_be_at(&mut self, value: u32, offset: usize) -> usize
Puts u32 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u32>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u32_be_at(0x1234 as u32, 2);
assert_eq!(written, size_of::<u32>());
// Value is written in big-endian format starting at offset 2Sourcefn put_u32_be_at_checked(&mut self, value: u32, offset: usize) -> Option<usize>
fn put_u32_be_at_checked(&mut self, value: u32, offset: usize) -> Option<usize>
Tries to put u32 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u32_be_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u32_be_at_checked(0x1234 as u32, 2).is_some());
assert!(slice.put_u32_be_at_checked(0x1234 as u32, 30).is_none()); // Out of boundsSourcefn try_put_u32_be_at(
&mut self,
value: u32,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u32_be_at( &mut self, value: u32, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u32 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u32_be_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u32_be_at(0x1234 as u32, 2).is_ok());
let err = slice.try_put_u32_be_at(0x1234 as u32, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u32_ne_at(&mut self, value: u32, offset: usize) -> usize
fn put_u32_ne_at(&mut self, value: u32, offset: usize) -> usize
Puts u32 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u32>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u32_ne_at(0x1234 as u32, 2);
assert_eq!(written, size_of::<u32>());
// Value is written in native-endian format starting at offset 2Sourcefn put_u32_ne_at_checked(&mut self, value: u32, offset: usize) -> Option<usize>
fn put_u32_ne_at_checked(&mut self, value: u32, offset: usize) -> Option<usize>
Tries to put u32 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u32_ne_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u32_ne_at_checked(0x1234 as u32, 2).is_some());
assert!(slice.put_u32_ne_at_checked(0x1234 as u32, 30).is_none()); // Out of boundsSourcefn try_put_u32_ne_at(
&mut self,
value: u32,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u32_ne_at( &mut self, value: u32, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u32 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u32_ne_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u32_ne_at(0x1234 as u32, 2).is_ok());
let err = slice.try_put_u32_ne_at(0x1234 as u32, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u32_le(&mut self, value: u32) -> usize
fn put_u32_le(&mut self, value: u32) -> usize
Puts u32 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u32_le(0x1234 as u32);
assert_eq!(written, size_of::<u32>());
// Value is written in little-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u32_le_checked(&mut self, value: u32) -> Option<usize>
fn put_u32_le_checked(&mut self, value: u32) -> Option<usize>
Tries to put u32 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u32_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u32_le_checked(0x1234 as u32).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u32_le_checked(0x1234 as u32).is_none()); // Not enough spaceSourcefn try_put_u32_le(&mut self, value: u32) -> Result<usize, TryWriteError>
fn try_put_u32_le(&mut self, value: u32) -> Result<usize, TryWriteError>
Tries to put u32 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u32_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u32_le(0x1234 as u32).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u32_le(0x1234 as u32).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u32_be(&mut self, value: u32) -> usize
fn put_u32_be(&mut self, value: u32) -> usize
Puts a u32 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u32_be(0x1234 as u32);
assert_eq!(written, size_of::<u32>());
// Value is written in big-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u32_be_checked(&mut self, value: u32) -> Option<usize>
fn put_u32_be_checked(&mut self, value: u32) -> Option<usize>
Tries to put u32 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u32_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u32_be_checked(0x1234 as u32).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u32_be_checked(0x1234 as u32).is_none()); // Not enough spaceSourcefn try_put_u32_be(&mut self, value: u32) -> Result<usize, TryWriteError>
fn try_put_u32_be(&mut self, value: u32) -> Result<usize, TryWriteError>
Tries to put u32 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u32_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u32_be(0x1234 as u32).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u32_be(0x1234 as u32).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u32_ne(&mut self, value: u32) -> usize
fn put_u32_ne(&mut self, value: u32) -> usize
Puts u32 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u32_ne(0x1234 as u32);
assert_eq!(written, size_of::<u32>());
// Value is written in native-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u32_ne_checked(&mut self, value: u32) -> Option<usize>
fn put_u32_ne_checked(&mut self, value: u32) -> Option<usize>
Tries to put u32 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u32_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u32_ne_checked(0x1234 as u32).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u32_ne_checked(0x1234 as u32).is_none()); // Not enough spaceSourcefn try_put_u32_ne(&mut self, value: u32) -> Result<usize, TryWriteError>
fn try_put_u32_ne(&mut self, value: u32) -> Result<usize, TryWriteError>
Tries to put u32 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u32_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u32_ne(0x1234 as u32).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u32_ne(0x1234 as u32).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u64_le_at(&mut self, value: u64, offset: usize) -> usize
fn put_u64_le_at(&mut self, value: u64, offset: usize) -> usize
Puts a u64 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u64>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u64_le_at(0x1234 as u64, 2);
assert_eq!(written, size_of::<u64>());
// Value is written in little-endian format starting at offset 2Sourcefn put_u64_le_at_checked(&mut self, value: u64, offset: usize) -> Option<usize>
fn put_u64_le_at_checked(&mut self, value: u64, offset: usize) -> Option<usize>
Tries to put u64 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u64_le_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u64_le_at_checked(0x1234 as u64, 2).is_some());
assert!(slice.put_u64_le_at_checked(0x1234 as u64, 30).is_none()); // Out of boundsSourcefn try_put_u64_le_at(
&mut self,
value: u64,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u64_le_at( &mut self, value: u64, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u64 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u64_le_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u64_le_at(0x1234 as u64, 2).is_ok());
let err = slice.try_put_u64_le_at(0x1234 as u64, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u64_be_at(&mut self, value: u64, offset: usize) -> usize
fn put_u64_be_at(&mut self, value: u64, offset: usize) -> usize
Puts u64 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u64>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u64_be_at(0x1234 as u64, 2);
assert_eq!(written, size_of::<u64>());
// Value is written in big-endian format starting at offset 2Sourcefn put_u64_be_at_checked(&mut self, value: u64, offset: usize) -> Option<usize>
fn put_u64_be_at_checked(&mut self, value: u64, offset: usize) -> Option<usize>
Tries to put u64 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u64_be_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u64_be_at_checked(0x1234 as u64, 2).is_some());
assert!(slice.put_u64_be_at_checked(0x1234 as u64, 30).is_none()); // Out of boundsSourcefn try_put_u64_be_at(
&mut self,
value: u64,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u64_be_at( &mut self, value: u64, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u64 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u64_be_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u64_be_at(0x1234 as u64, 2).is_ok());
let err = slice.try_put_u64_be_at(0x1234 as u64, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u64_ne_at(&mut self, value: u64, offset: usize) -> usize
fn put_u64_ne_at(&mut self, value: u64, offset: usize) -> usize
Puts u64 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u64>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u64_ne_at(0x1234 as u64, 2);
assert_eq!(written, size_of::<u64>());
// Value is written in native-endian format starting at offset 2Sourcefn put_u64_ne_at_checked(&mut self, value: u64, offset: usize) -> Option<usize>
fn put_u64_ne_at_checked(&mut self, value: u64, offset: usize) -> Option<usize>
Tries to put u64 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u64_ne_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u64_ne_at_checked(0x1234 as u64, 2).is_some());
assert!(slice.put_u64_ne_at_checked(0x1234 as u64, 30).is_none()); // Out of boundsSourcefn try_put_u64_ne_at(
&mut self,
value: u64,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u64_ne_at( &mut self, value: u64, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u64 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u64_ne_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u64_ne_at(0x1234 as u64, 2).is_ok());
let err = slice.try_put_u64_ne_at(0x1234 as u64, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u64_le(&mut self, value: u64) -> usize
fn put_u64_le(&mut self, value: u64) -> usize
Puts u64 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u64_le(0x1234 as u64);
assert_eq!(written, size_of::<u64>());
// Value is written in little-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u64_le_checked(&mut self, value: u64) -> Option<usize>
fn put_u64_le_checked(&mut self, value: u64) -> Option<usize>
Tries to put u64 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u64_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u64_le_checked(0x1234 as u64).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u64_le_checked(0x1234 as u64).is_none()); // Not enough spaceSourcefn try_put_u64_le(&mut self, value: u64) -> Result<usize, TryWriteError>
fn try_put_u64_le(&mut self, value: u64) -> Result<usize, TryWriteError>
Tries to put u64 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u64_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u64_le(0x1234 as u64).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u64_le(0x1234 as u64).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u64_be(&mut self, value: u64) -> usize
fn put_u64_be(&mut self, value: u64) -> usize
Puts a u64 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u64_be(0x1234 as u64);
assert_eq!(written, size_of::<u64>());
// Value is written in big-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u64_be_checked(&mut self, value: u64) -> Option<usize>
fn put_u64_be_checked(&mut self, value: u64) -> Option<usize>
Tries to put u64 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u64_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u64_be_checked(0x1234 as u64).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u64_be_checked(0x1234 as u64).is_none()); // Not enough spaceSourcefn try_put_u64_be(&mut self, value: u64) -> Result<usize, TryWriteError>
fn try_put_u64_be(&mut self, value: u64) -> Result<usize, TryWriteError>
Tries to put u64 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u64_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u64_be(0x1234 as u64).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u64_be(0x1234 as u64).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u64_ne(&mut self, value: u64) -> usize
fn put_u64_ne(&mut self, value: u64) -> usize
Puts u64 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u64_ne(0x1234 as u64);
assert_eq!(written, size_of::<u64>());
// Value is written in native-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u64_ne_checked(&mut self, value: u64) -> Option<usize>
fn put_u64_ne_checked(&mut self, value: u64) -> Option<usize>
Tries to put u64 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u64_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u64_ne_checked(0x1234 as u64).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u64_ne_checked(0x1234 as u64).is_none()); // Not enough spaceSourcefn try_put_u64_ne(&mut self, value: u64) -> Result<usize, TryWriteError>
fn try_put_u64_ne(&mut self, value: u64) -> Result<usize, TryWriteError>
Tries to put u64 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u64_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u64_ne(0x1234 as u64).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u64_ne(0x1234 as u64).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u128_le_at(&mut self, value: u128, offset: usize) -> usize
fn put_u128_le_at(&mut self, value: u128, offset: usize) -> usize
Puts a u128 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u128>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u128_le_at(0x1234 as u128, 2);
assert_eq!(written, size_of::<u128>());
// Value is written in little-endian format starting at offset 2Sourcefn put_u128_le_at_checked(
&mut self,
value: u128,
offset: usize,
) -> Option<usize>
fn put_u128_le_at_checked( &mut self, value: u128, offset: usize, ) -> Option<usize>
Tries to put u128 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u128_le_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u128_le_at_checked(0x1234 as u128, 2).is_some());
assert!(slice.put_u128_le_at_checked(0x1234 as u128, 30).is_none()); // Out of boundsSourcefn try_put_u128_le_at(
&mut self,
value: u128,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u128_le_at( &mut self, value: u128, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u128 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u128_le_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u128_le_at(0x1234 as u128, 2).is_ok());
let err = slice.try_put_u128_le_at(0x1234 as u128, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u128_be_at(&mut self, value: u128, offset: usize) -> usize
fn put_u128_be_at(&mut self, value: u128, offset: usize) -> usize
Puts u128 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u128>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u128_be_at(0x1234 as u128, 2);
assert_eq!(written, size_of::<u128>());
// Value is written in big-endian format starting at offset 2Sourcefn put_u128_be_at_checked(
&mut self,
value: u128,
offset: usize,
) -> Option<usize>
fn put_u128_be_at_checked( &mut self, value: u128, offset: usize, ) -> Option<usize>
Tries to put u128 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u128_be_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u128_be_at_checked(0x1234 as u128, 2).is_some());
assert!(slice.put_u128_be_at_checked(0x1234 as u128, 30).is_none()); // Out of boundsSourcefn try_put_u128_be_at(
&mut self,
value: u128,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u128_be_at( &mut self, value: u128, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u128 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u128_be_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u128_be_at(0x1234 as u128, 2).is_ok());
let err = slice.try_put_u128_be_at(0x1234 as u128, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u128_ne_at(&mut self, value: u128, offset: usize) -> usize
fn put_u128_ne_at(&mut self, value: u128, offset: usize) -> usize
Puts u128 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u128>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u128_ne_at(0x1234 as u128, 2);
assert_eq!(written, size_of::<u128>());
// Value is written in native-endian format starting at offset 2Sourcefn put_u128_ne_at_checked(
&mut self,
value: u128,
offset: usize,
) -> Option<usize>
fn put_u128_ne_at_checked( &mut self, value: u128, offset: usize, ) -> Option<usize>
Tries to put u128 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u128_ne_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u128_ne_at_checked(0x1234 as u128, 2).is_some());
assert!(slice.put_u128_ne_at_checked(0x1234 as u128, 30).is_none()); // Out of boundsSourcefn try_put_u128_ne_at(
&mut self,
value: u128,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u128_ne_at( &mut self, value: u128, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u128 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u128_ne_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u128_ne_at(0x1234 as u128, 2).is_ok());
let err = slice.try_put_u128_ne_at(0x1234 as u128, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_u128_le(&mut self, value: u128) -> usize
fn put_u128_le(&mut self, value: u128) -> usize
Puts u128 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u128_le(0x1234 as u128);
assert_eq!(written, size_of::<u128>());
// Value is written in little-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u128_le_checked(&mut self, value: u128) -> Option<usize>
fn put_u128_le_checked(&mut self, value: u128) -> Option<usize>
Tries to put u128 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u128_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u128_le_checked(0x1234 as u128).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u128_le_checked(0x1234 as u128).is_none()); // Not enough spaceSourcefn try_put_u128_le(&mut self, value: u128) -> Result<usize, TryWriteError>
fn try_put_u128_le(&mut self, value: u128) -> Result<usize, TryWriteError>
Tries to put u128 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u128_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u128_le(0x1234 as u128).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u128_le(0x1234 as u128).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u128_be(&mut self, value: u128) -> usize
fn put_u128_be(&mut self, value: u128) -> usize
Puts a u128 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<u128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u128_be(0x1234 as u128);
assert_eq!(written, size_of::<u128>());
// Value is written in big-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u128_be_checked(&mut self, value: u128) -> Option<usize>
fn put_u128_be_checked(&mut self, value: u128) -> Option<usize>
Tries to put u128 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u128_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u128_be_checked(0x1234 as u128).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u128_be_checked(0x1234 as u128).is_none()); // Not enough spaceSourcefn try_put_u128_be(&mut self, value: u128) -> Result<usize, TryWriteError>
fn try_put_u128_be(&mut self, value: u128) -> Result<usize, TryWriteError>
Tries to put u128 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u128_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u128_be(0x1234 as u128).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u128_be(0x1234 as u128).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u128_ne(&mut self, value: u128) -> usize
fn put_u128_ne(&mut self, value: u128) -> usize
Puts u128 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<u128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u128_ne(0x1234 as u128);
assert_eq!(written, size_of::<u128>());
// Value is written in native-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_u128_ne_checked(&mut self, value: u128) -> Option<usize>
fn put_u128_ne_checked(&mut self, value: u128) -> Option<usize>
Tries to put u128 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u128_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_u128_ne_checked(0x1234 as u128).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_u128_ne_checked(0x1234 as u128).is_none()); // Not enough spaceSourcefn try_put_u128_ne(&mut self, value: u128) -> Result<usize, TryWriteError>
fn try_put_u128_ne(&mut self, value: u128) -> Result<usize, TryWriteError>
Tries to put u128 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_u128_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u128_ne(0x1234 as u128).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_u128_ne(0x1234 as u128).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i16_le_at(&mut self, value: i16, offset: usize) -> usize
fn put_i16_le_at(&mut self, value: i16, offset: usize) -> usize
Puts a i16 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i16>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i16_le_at(0x1234 as i16, 2);
assert_eq!(written, size_of::<i16>());
// Value is written in little-endian format starting at offset 2Sourcefn put_i16_le_at_checked(&mut self, value: i16, offset: usize) -> Option<usize>
fn put_i16_le_at_checked(&mut self, value: i16, offset: usize) -> Option<usize>
Tries to put i16 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i16_le_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i16_le_at_checked(0x1234 as i16, 2).is_some());
assert!(slice.put_i16_le_at_checked(0x1234 as i16, 30).is_none()); // Out of boundsSourcefn try_put_i16_le_at(
&mut self,
value: i16,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i16_le_at( &mut self, value: i16, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i16 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i16_le_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i16_le_at(0x1234 as i16, 2).is_ok());
let err = slice.try_put_i16_le_at(0x1234 as i16, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i16_be_at(&mut self, value: i16, offset: usize) -> usize
fn put_i16_be_at(&mut self, value: i16, offset: usize) -> usize
Puts i16 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i16>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i16_be_at(0x1234 as i16, 2);
assert_eq!(written, size_of::<i16>());
// Value is written in big-endian format starting at offset 2Sourcefn put_i16_be_at_checked(&mut self, value: i16, offset: usize) -> Option<usize>
fn put_i16_be_at_checked(&mut self, value: i16, offset: usize) -> Option<usize>
Tries to put i16 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i16_be_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i16_be_at_checked(0x1234 as i16, 2).is_some());
assert!(slice.put_i16_be_at_checked(0x1234 as i16, 30).is_none()); // Out of boundsSourcefn try_put_i16_be_at(
&mut self,
value: i16,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i16_be_at( &mut self, value: i16, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i16 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i16_be_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i16_be_at(0x1234 as i16, 2).is_ok());
let err = slice.try_put_i16_be_at(0x1234 as i16, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i16_ne_at(&mut self, value: i16, offset: usize) -> usize
fn put_i16_ne_at(&mut self, value: i16, offset: usize) -> usize
Puts i16 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i16>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i16_ne_at(0x1234 as i16, 2);
assert_eq!(written, size_of::<i16>());
// Value is written in native-endian format starting at offset 2Sourcefn put_i16_ne_at_checked(&mut self, value: i16, offset: usize) -> Option<usize>
fn put_i16_ne_at_checked(&mut self, value: i16, offset: usize) -> Option<usize>
Tries to put i16 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i16_ne_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i16_ne_at_checked(0x1234 as i16, 2).is_some());
assert!(slice.put_i16_ne_at_checked(0x1234 as i16, 30).is_none()); // Out of boundsSourcefn try_put_i16_ne_at(
&mut self,
value: i16,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i16_ne_at( &mut self, value: i16, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i16 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i16_ne_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i16_ne_at(0x1234 as i16, 2).is_ok());
let err = slice.try_put_i16_ne_at(0x1234 as i16, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i16_le(&mut self, value: i16) -> usize
fn put_i16_le(&mut self, value: i16) -> usize
Puts i16 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i16_le(0x1234 as i16);
assert_eq!(written, size_of::<i16>());
// Value is written in little-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i16_le_checked(&mut self, value: i16) -> Option<usize>
fn put_i16_le_checked(&mut self, value: i16) -> Option<usize>
Tries to put i16 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i16_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i16_le_checked(0x1234 as i16).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i16_le_checked(0x1234 as i16).is_none()); // Not enough spaceSourcefn try_put_i16_le(&mut self, value: i16) -> Result<usize, TryWriteError>
fn try_put_i16_le(&mut self, value: i16) -> Result<usize, TryWriteError>
Tries to put i16 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i16_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i16_le(0x1234 as i16).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i16_le(0x1234 as i16).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i16_be(&mut self, value: i16) -> usize
fn put_i16_be(&mut self, value: i16) -> usize
Puts a i16 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i16_be(0x1234 as i16);
assert_eq!(written, size_of::<i16>());
// Value is written in big-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i16_be_checked(&mut self, value: i16) -> Option<usize>
fn put_i16_be_checked(&mut self, value: i16) -> Option<usize>
Tries to put i16 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i16_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i16_be_checked(0x1234 as i16).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i16_be_checked(0x1234 as i16).is_none()); // Not enough spaceSourcefn try_put_i16_be(&mut self, value: i16) -> Result<usize, TryWriteError>
fn try_put_i16_be(&mut self, value: i16) -> Result<usize, TryWriteError>
Tries to put i16 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i16_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i16_be(0x1234 as i16).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i16_be(0x1234 as i16).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i16_ne(&mut self, value: i16) -> usize
fn put_i16_ne(&mut self, value: i16) -> usize
Puts i16 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i16>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i16_ne(0x1234 as i16);
assert_eq!(written, size_of::<i16>());
// Value is written in native-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i16_ne_checked(&mut self, value: i16) -> Option<usize>
fn put_i16_ne_checked(&mut self, value: i16) -> Option<usize>
Tries to put i16 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i16_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i16_ne_checked(0x1234 as i16).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i16_ne_checked(0x1234 as i16).is_none()); // Not enough spaceSourcefn try_put_i16_ne(&mut self, value: i16) -> Result<usize, TryWriteError>
fn try_put_i16_ne(&mut self, value: i16) -> Result<usize, TryWriteError>
Tries to put i16 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i16_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i16_ne(0x1234 as i16).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i16_ne(0x1234 as i16).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i32_le_at(&mut self, value: i32, offset: usize) -> usize
fn put_i32_le_at(&mut self, value: i32, offset: usize) -> usize
Puts a i32 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i32>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i32_le_at(0x1234 as i32, 2);
assert_eq!(written, size_of::<i32>());
// Value is written in little-endian format starting at offset 2Sourcefn put_i32_le_at_checked(&mut self, value: i32, offset: usize) -> Option<usize>
fn put_i32_le_at_checked(&mut self, value: i32, offset: usize) -> Option<usize>
Tries to put i32 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i32_le_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i32_le_at_checked(0x1234 as i32, 2).is_some());
assert!(slice.put_i32_le_at_checked(0x1234 as i32, 30).is_none()); // Out of boundsSourcefn try_put_i32_le_at(
&mut self,
value: i32,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i32_le_at( &mut self, value: i32, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i32 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i32_le_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i32_le_at(0x1234 as i32, 2).is_ok());
let err = slice.try_put_i32_le_at(0x1234 as i32, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i32_be_at(&mut self, value: i32, offset: usize) -> usize
fn put_i32_be_at(&mut self, value: i32, offset: usize) -> usize
Puts i32 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i32>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i32_be_at(0x1234 as i32, 2);
assert_eq!(written, size_of::<i32>());
// Value is written in big-endian format starting at offset 2Sourcefn put_i32_be_at_checked(&mut self, value: i32, offset: usize) -> Option<usize>
fn put_i32_be_at_checked(&mut self, value: i32, offset: usize) -> Option<usize>
Tries to put i32 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i32_be_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i32_be_at_checked(0x1234 as i32, 2).is_some());
assert!(slice.put_i32_be_at_checked(0x1234 as i32, 30).is_none()); // Out of boundsSourcefn try_put_i32_be_at(
&mut self,
value: i32,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i32_be_at( &mut self, value: i32, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i32 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i32_be_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i32_be_at(0x1234 as i32, 2).is_ok());
let err = slice.try_put_i32_be_at(0x1234 as i32, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i32_ne_at(&mut self, value: i32, offset: usize) -> usize
fn put_i32_ne_at(&mut self, value: i32, offset: usize) -> usize
Puts i32 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i32>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i32_ne_at(0x1234 as i32, 2);
assert_eq!(written, size_of::<i32>());
// Value is written in native-endian format starting at offset 2Sourcefn put_i32_ne_at_checked(&mut self, value: i32, offset: usize) -> Option<usize>
fn put_i32_ne_at_checked(&mut self, value: i32, offset: usize) -> Option<usize>
Tries to put i32 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i32_ne_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i32_ne_at_checked(0x1234 as i32, 2).is_some());
assert!(slice.put_i32_ne_at_checked(0x1234 as i32, 30).is_none()); // Out of boundsSourcefn try_put_i32_ne_at(
&mut self,
value: i32,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i32_ne_at( &mut self, value: i32, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i32 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i32_ne_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i32_ne_at(0x1234 as i32, 2).is_ok());
let err = slice.try_put_i32_ne_at(0x1234 as i32, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i32_le(&mut self, value: i32) -> usize
fn put_i32_le(&mut self, value: i32) -> usize
Puts i32 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i32_le(0x1234 as i32);
assert_eq!(written, size_of::<i32>());
// Value is written in little-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i32_le_checked(&mut self, value: i32) -> Option<usize>
fn put_i32_le_checked(&mut self, value: i32) -> Option<usize>
Tries to put i32 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i32_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i32_le_checked(0x1234 as i32).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i32_le_checked(0x1234 as i32).is_none()); // Not enough spaceSourcefn try_put_i32_le(&mut self, value: i32) -> Result<usize, TryWriteError>
fn try_put_i32_le(&mut self, value: i32) -> Result<usize, TryWriteError>
Tries to put i32 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i32_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i32_le(0x1234 as i32).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i32_le(0x1234 as i32).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i32_be(&mut self, value: i32) -> usize
fn put_i32_be(&mut self, value: i32) -> usize
Puts a i32 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i32_be(0x1234 as i32);
assert_eq!(written, size_of::<i32>());
// Value is written in big-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i32_be_checked(&mut self, value: i32) -> Option<usize>
fn put_i32_be_checked(&mut self, value: i32) -> Option<usize>
Tries to put i32 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i32_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i32_be_checked(0x1234 as i32).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i32_be_checked(0x1234 as i32).is_none()); // Not enough spaceSourcefn try_put_i32_be(&mut self, value: i32) -> Result<usize, TryWriteError>
fn try_put_i32_be(&mut self, value: i32) -> Result<usize, TryWriteError>
Tries to put i32 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i32_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i32_be(0x1234 as i32).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i32_be(0x1234 as i32).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i32_ne(&mut self, value: i32) -> usize
fn put_i32_ne(&mut self, value: i32) -> usize
Puts i32 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i32_ne(0x1234 as i32);
assert_eq!(written, size_of::<i32>());
// Value is written in native-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i32_ne_checked(&mut self, value: i32) -> Option<usize>
fn put_i32_ne_checked(&mut self, value: i32) -> Option<usize>
Tries to put i32 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i32_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i32_ne_checked(0x1234 as i32).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i32_ne_checked(0x1234 as i32).is_none()); // Not enough spaceSourcefn try_put_i32_ne(&mut self, value: i32) -> Result<usize, TryWriteError>
fn try_put_i32_ne(&mut self, value: i32) -> Result<usize, TryWriteError>
Tries to put i32 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i32_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i32_ne(0x1234 as i32).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i32_ne(0x1234 as i32).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i64_le_at(&mut self, value: i64, offset: usize) -> usize
fn put_i64_le_at(&mut self, value: i64, offset: usize) -> usize
Puts a i64 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i64>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i64_le_at(0x1234 as i64, 2);
assert_eq!(written, size_of::<i64>());
// Value is written in little-endian format starting at offset 2Sourcefn put_i64_le_at_checked(&mut self, value: i64, offset: usize) -> Option<usize>
fn put_i64_le_at_checked(&mut self, value: i64, offset: usize) -> Option<usize>
Tries to put i64 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i64_le_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i64_le_at_checked(0x1234 as i64, 2).is_some());
assert!(slice.put_i64_le_at_checked(0x1234 as i64, 30).is_none()); // Out of boundsSourcefn try_put_i64_le_at(
&mut self,
value: i64,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i64_le_at( &mut self, value: i64, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i64 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i64_le_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i64_le_at(0x1234 as i64, 2).is_ok());
let err = slice.try_put_i64_le_at(0x1234 as i64, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i64_be_at(&mut self, value: i64, offset: usize) -> usize
fn put_i64_be_at(&mut self, value: i64, offset: usize) -> usize
Puts i64 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i64>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i64_be_at(0x1234 as i64, 2);
assert_eq!(written, size_of::<i64>());
// Value is written in big-endian format starting at offset 2Sourcefn put_i64_be_at_checked(&mut self, value: i64, offset: usize) -> Option<usize>
fn put_i64_be_at_checked(&mut self, value: i64, offset: usize) -> Option<usize>
Tries to put i64 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i64_be_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i64_be_at_checked(0x1234 as i64, 2).is_some());
assert!(slice.put_i64_be_at_checked(0x1234 as i64, 30).is_none()); // Out of boundsSourcefn try_put_i64_be_at(
&mut self,
value: i64,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i64_be_at( &mut self, value: i64, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i64 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i64_be_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i64_be_at(0x1234 as i64, 2).is_ok());
let err = slice.try_put_i64_be_at(0x1234 as i64, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i64_ne_at(&mut self, value: i64, offset: usize) -> usize
fn put_i64_ne_at(&mut self, value: i64, offset: usize) -> usize
Puts i64 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i64>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i64_ne_at(0x1234 as i64, 2);
assert_eq!(written, size_of::<i64>());
// Value is written in native-endian format starting at offset 2Sourcefn put_i64_ne_at_checked(&mut self, value: i64, offset: usize) -> Option<usize>
fn put_i64_ne_at_checked(&mut self, value: i64, offset: usize) -> Option<usize>
Tries to put i64 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i64_ne_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i64_ne_at_checked(0x1234 as i64, 2).is_some());
assert!(slice.put_i64_ne_at_checked(0x1234 as i64, 30).is_none()); // Out of boundsSourcefn try_put_i64_ne_at(
&mut self,
value: i64,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i64_ne_at( &mut self, value: i64, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i64 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i64_ne_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i64_ne_at(0x1234 as i64, 2).is_ok());
let err = slice.try_put_i64_ne_at(0x1234 as i64, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i64_le(&mut self, value: i64) -> usize
fn put_i64_le(&mut self, value: i64) -> usize
Puts i64 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i64_le(0x1234 as i64);
assert_eq!(written, size_of::<i64>());
// Value is written in little-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i64_le_checked(&mut self, value: i64) -> Option<usize>
fn put_i64_le_checked(&mut self, value: i64) -> Option<usize>
Tries to put i64 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i64_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i64_le_checked(0x1234 as i64).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i64_le_checked(0x1234 as i64).is_none()); // Not enough spaceSourcefn try_put_i64_le(&mut self, value: i64) -> Result<usize, TryWriteError>
fn try_put_i64_le(&mut self, value: i64) -> Result<usize, TryWriteError>
Tries to put i64 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i64_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i64_le(0x1234 as i64).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i64_le(0x1234 as i64).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i64_be(&mut self, value: i64) -> usize
fn put_i64_be(&mut self, value: i64) -> usize
Puts a i64 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i64_be(0x1234 as i64);
assert_eq!(written, size_of::<i64>());
// Value is written in big-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i64_be_checked(&mut self, value: i64) -> Option<usize>
fn put_i64_be_checked(&mut self, value: i64) -> Option<usize>
Tries to put i64 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i64_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i64_be_checked(0x1234 as i64).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i64_be_checked(0x1234 as i64).is_none()); // Not enough spaceSourcefn try_put_i64_be(&mut self, value: i64) -> Result<usize, TryWriteError>
fn try_put_i64_be(&mut self, value: i64) -> Result<usize, TryWriteError>
Tries to put i64 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i64_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i64_be(0x1234 as i64).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i64_be(0x1234 as i64).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i64_ne(&mut self, value: i64) -> usize
fn put_i64_ne(&mut self, value: i64) -> usize
Puts i64 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i64_ne(0x1234 as i64);
assert_eq!(written, size_of::<i64>());
// Value is written in native-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i64_ne_checked(&mut self, value: i64) -> Option<usize>
fn put_i64_ne_checked(&mut self, value: i64) -> Option<usize>
Tries to put i64 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i64_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i64_ne_checked(0x1234 as i64).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i64_ne_checked(0x1234 as i64).is_none()); // Not enough spaceSourcefn try_put_i64_ne(&mut self, value: i64) -> Result<usize, TryWriteError>
fn try_put_i64_ne(&mut self, value: i64) -> Result<usize, TryWriteError>
Tries to put i64 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i64_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i64_ne(0x1234 as i64).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i64_ne(0x1234 as i64).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i128_le_at(&mut self, value: i128, offset: usize) -> usize
fn put_i128_le_at(&mut self, value: i128, offset: usize) -> usize
Puts a i128 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i128>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i128_le_at(0x1234 as i128, 2);
assert_eq!(written, size_of::<i128>());
// Value is written in little-endian format starting at offset 2Sourcefn put_i128_le_at_checked(
&mut self,
value: i128,
offset: usize,
) -> Option<usize>
fn put_i128_le_at_checked( &mut self, value: i128, offset: usize, ) -> Option<usize>
Tries to put i128 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i128_le_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i128_le_at_checked(0x1234 as i128, 2).is_some());
assert!(slice.put_i128_le_at_checked(0x1234 as i128, 30).is_none()); // Out of boundsSourcefn try_put_i128_le_at(
&mut self,
value: i128,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i128_le_at( &mut self, value: i128, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i128 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i128_le_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i128_le_at(0x1234 as i128, 2).is_ok());
let err = slice.try_put_i128_le_at(0x1234 as i128, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i128_be_at(&mut self, value: i128, offset: usize) -> usize
fn put_i128_be_at(&mut self, value: i128, offset: usize) -> usize
Puts i128 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i128>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i128_be_at(0x1234 as i128, 2);
assert_eq!(written, size_of::<i128>());
// Value is written in big-endian format starting at offset 2Sourcefn put_i128_be_at_checked(
&mut self,
value: i128,
offset: usize,
) -> Option<usize>
fn put_i128_be_at_checked( &mut self, value: i128, offset: usize, ) -> Option<usize>
Tries to put i128 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i128_be_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i128_be_at_checked(0x1234 as i128, 2).is_some());
assert!(slice.put_i128_be_at_checked(0x1234 as i128, 30).is_none()); // Out of boundsSourcefn try_put_i128_be_at(
&mut self,
value: i128,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i128_be_at( &mut self, value: i128, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i128 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i128_be_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i128_be_at(0x1234 as i128, 2).is_ok());
let err = slice.try_put_i128_be_at(0x1234 as i128, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i128_ne_at(&mut self, value: i128, offset: usize) -> usize
fn put_i128_ne_at(&mut self, value: i128, offset: usize) -> usize
Puts i128 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i128>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i128_ne_at(0x1234 as i128, 2);
assert_eq!(written, size_of::<i128>());
// Value is written in native-endian format starting at offset 2Sourcefn put_i128_ne_at_checked(
&mut self,
value: i128,
offset: usize,
) -> Option<usize>
fn put_i128_ne_at_checked( &mut self, value: i128, offset: usize, ) -> Option<usize>
Tries to put i128 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i128_ne_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i128_ne_at_checked(0x1234 as i128, 2).is_some());
assert!(slice.put_i128_ne_at_checked(0x1234 as i128, 30).is_none()); // Out of boundsSourcefn try_put_i128_ne_at(
&mut self,
value: i128,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i128_ne_at( &mut self, value: i128, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i128 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i128_ne_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i128_ne_at(0x1234 as i128, 2).is_ok());
let err = slice.try_put_i128_ne_at(0x1234 as i128, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_i128_le(&mut self, value: i128) -> usize
fn put_i128_le(&mut self, value: i128) -> usize
Puts i128 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i128_le(0x1234 as i128);
assert_eq!(written, size_of::<i128>());
// Value is written in little-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i128_le_checked(&mut self, value: i128) -> Option<usize>
fn put_i128_le_checked(&mut self, value: i128) -> Option<usize>
Tries to put i128 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i128_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i128_le_checked(0x1234 as i128).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i128_le_checked(0x1234 as i128).is_none()); // Not enough spaceSourcefn try_put_i128_le(&mut self, value: i128) -> Result<usize, TryWriteError>
fn try_put_i128_le(&mut self, value: i128) -> Result<usize, TryWriteError>
Tries to put i128 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i128_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i128_le(0x1234 as i128).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i128_le(0x1234 as i128).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i128_be(&mut self, value: i128) -> usize
fn put_i128_be(&mut self, value: i128) -> usize
Puts a i128 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<i128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i128_be(0x1234 as i128);
assert_eq!(written, size_of::<i128>());
// Value is written in big-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i128_be_checked(&mut self, value: i128) -> Option<usize>
fn put_i128_be_checked(&mut self, value: i128) -> Option<usize>
Tries to put i128 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i128_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i128_be_checked(0x1234 as i128).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i128_be_checked(0x1234 as i128).is_none()); // Not enough spaceSourcefn try_put_i128_be(&mut self, value: i128) -> Result<usize, TryWriteError>
fn try_put_i128_be(&mut self, value: i128) -> Result<usize, TryWriteError>
Tries to put i128 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i128_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i128_be(0x1234 as i128).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i128_be(0x1234 as i128).unwrap_err();
// err contains information about required vs available spaceSourcefn put_i128_ne(&mut self, value: i128) -> usize
fn put_i128_ne(&mut self, value: i128) -> usize
Puts i128 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<i128>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i128_ne(0x1234 as i128);
assert_eq!(written, size_of::<i128>());
// Value is written in native-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_i128_ne_checked(&mut self, value: i128) -> Option<usize>
fn put_i128_ne_checked(&mut self, value: i128) -> Option<usize>
Tries to put i128 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i128_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_i128_ne_checked(0x1234 as i128).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_i128_ne_checked(0x1234 as i128).is_none()); // Not enough spaceSourcefn try_put_i128_ne(&mut self, value: i128) -> Result<usize, TryWriteError>
fn try_put_i128_ne(&mut self, value: i128) -> Result<usize, TryWriteError>
Tries to put i128 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_i128_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i128_ne(0x1234 as i128).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_i128_ne(0x1234 as i128).unwrap_err();
// err contains information about required vs available spaceSourcefn put_f32_le_at(&mut self, value: f32, offset: usize) -> usize
fn put_f32_le_at(&mut self, value: f32, offset: usize) -> usize
Puts a f32 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<f32>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f32_le_at(0x1234 as f32, 2);
assert_eq!(written, size_of::<f32>());
// Value is written in little-endian format starting at offset 2Sourcefn put_f32_le_at_checked(&mut self, value: f32, offset: usize) -> Option<usize>
fn put_f32_le_at_checked(&mut self, value: f32, offset: usize) -> Option<usize>
Tries to put f32 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_f32_le_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f32_le_at_checked(0x1234 as f32, 2).is_some());
assert!(slice.put_f32_le_at_checked(0x1234 as f32, 30).is_none()); // Out of boundsSourcefn try_put_f32_le_at(
&mut self,
value: f32,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_f32_le_at( &mut self, value: f32, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put f32 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_f32_le_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f32_le_at(0x1234 as f32, 2).is_ok());
let err = slice.try_put_f32_le_at(0x1234 as f32, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_f32_be_at(&mut self, value: f32, offset: usize) -> usize
fn put_f32_be_at(&mut self, value: f32, offset: usize) -> usize
Puts f32 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<f32>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f32_be_at(0x1234 as f32, 2);
assert_eq!(written, size_of::<f32>());
// Value is written in big-endian format starting at offset 2Sourcefn put_f32_be_at_checked(&mut self, value: f32, offset: usize) -> Option<usize>
fn put_f32_be_at_checked(&mut self, value: f32, offset: usize) -> Option<usize>
Tries to put f32 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_f32_be_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f32_be_at_checked(0x1234 as f32, 2).is_some());
assert!(slice.put_f32_be_at_checked(0x1234 as f32, 30).is_none()); // Out of boundsSourcefn try_put_f32_be_at(
&mut self,
value: f32,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_f32_be_at( &mut self, value: f32, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put f32 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_f32_be_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f32_be_at(0x1234 as f32, 2).is_ok());
let err = slice.try_put_f32_be_at(0x1234 as f32, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_f32_ne_at(&mut self, value: f32, offset: usize) -> usize
fn put_f32_ne_at(&mut self, value: f32, offset: usize) -> usize
Puts f32 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<f32>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f32_ne_at(0x1234 as f32, 2);
assert_eq!(written, size_of::<f32>());
// Value is written in native-endian format starting at offset 2Sourcefn put_f32_ne_at_checked(&mut self, value: f32, offset: usize) -> Option<usize>
fn put_f32_ne_at_checked(&mut self, value: f32, offset: usize) -> Option<usize>
Tries to put f32 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_f32_ne_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f32_ne_at_checked(0x1234 as f32, 2).is_some());
assert!(slice.put_f32_ne_at_checked(0x1234 as f32, 30).is_none()); // Out of boundsSourcefn try_put_f32_ne_at(
&mut self,
value: f32,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_f32_ne_at( &mut self, value: f32, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put f32 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_f32_ne_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f32_ne_at(0x1234 as f32, 2).is_ok());
let err = slice.try_put_f32_ne_at(0x1234 as f32, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_f32_le(&mut self, value: f32) -> usize
fn put_f32_le(&mut self, value: f32) -> usize
Puts f32 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<f32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f32_le(0x1234 as f32);
assert_eq!(written, size_of::<f32>());
// Value is written in little-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_f32_le_checked(&mut self, value: f32) -> Option<usize>
fn put_f32_le_checked(&mut self, value: f32) -> Option<usize>
Tries to put f32 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_f32_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f32_le_checked(0x1234 as f32).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_f32_le_checked(0x1234 as f32).is_none()); // Not enough spaceSourcefn try_put_f32_le(&mut self, value: f32) -> Result<usize, TryWriteError>
fn try_put_f32_le(&mut self, value: f32) -> Result<usize, TryWriteError>
Tries to put f32 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_f32_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f32_le(0x1234 as f32).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_f32_le(0x1234 as f32).unwrap_err();
// err contains information about required vs available spaceSourcefn put_f32_be(&mut self, value: f32) -> usize
fn put_f32_be(&mut self, value: f32) -> usize
Puts a f32 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<f32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f32_be(0x1234 as f32);
assert_eq!(written, size_of::<f32>());
// Value is written in big-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_f32_be_checked(&mut self, value: f32) -> Option<usize>
fn put_f32_be_checked(&mut self, value: f32) -> Option<usize>
Tries to put f32 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_f32_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f32_be_checked(0x1234 as f32).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_f32_be_checked(0x1234 as f32).is_none()); // Not enough spaceSourcefn try_put_f32_be(&mut self, value: f32) -> Result<usize, TryWriteError>
fn try_put_f32_be(&mut self, value: f32) -> Result<usize, TryWriteError>
Tries to put f32 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_f32_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f32_be(0x1234 as f32).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_f32_be(0x1234 as f32).unwrap_err();
// err contains information about required vs available spaceSourcefn put_f32_ne(&mut self, value: f32) -> usize
fn put_f32_ne(&mut self, value: f32) -> usize
Puts f32 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<f32>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f32_ne(0x1234 as f32);
assert_eq!(written, size_of::<f32>());
// Value is written in native-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_f32_ne_checked(&mut self, value: f32) -> Option<usize>
fn put_f32_ne_checked(&mut self, value: f32) -> Option<usize>
Tries to put f32 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_f32_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f32_ne_checked(0x1234 as f32).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_f32_ne_checked(0x1234 as f32).is_none()); // Not enough spaceSourcefn try_put_f32_ne(&mut self, value: f32) -> Result<usize, TryWriteError>
fn try_put_f32_ne(&mut self, value: f32) -> Result<usize, TryWriteError>
Tries to put f32 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_f32_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f32_ne(0x1234 as f32).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_f32_ne(0x1234 as f32).unwrap_err();
// err contains information about required vs available spaceSourcefn put_f64_le_at(&mut self, value: f64, offset: usize) -> usize
fn put_f64_le_at(&mut self, value: f64, offset: usize) -> usize
Puts a f64 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<f64>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f64_le_at(0x1234 as f64, 2);
assert_eq!(written, size_of::<f64>());
// Value is written in little-endian format starting at offset 2Sourcefn put_f64_le_at_checked(&mut self, value: f64, offset: usize) -> Option<usize>
fn put_f64_le_at_checked(&mut self, value: f64, offset: usize) -> Option<usize>
Tries to put f64 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_f64_le_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f64_le_at_checked(0x1234 as f64, 2).is_some());
assert!(slice.put_f64_le_at_checked(0x1234 as f64, 30).is_none()); // Out of boundsSourcefn try_put_f64_le_at(
&mut self,
value: f64,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_f64_le_at( &mut self, value: f64, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put f64 value in little-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_f64_le_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f64_le_at(0x1234 as f64, 2).is_ok());
let err = slice.try_put_f64_le_at(0x1234 as f64, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_f64_be_at(&mut self, value: f64, offset: usize) -> usize
fn put_f64_be_at(&mut self, value: f64, offset: usize) -> usize
Puts f64 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always size_of::<f64>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f64_be_at(0x1234 as f64, 2);
assert_eq!(written, size_of::<f64>());
// Value is written in big-endian format starting at offset 2Sourcefn put_f64_be_at_checked(&mut self, value: f64, offset: usize) -> Option<usize>
fn put_f64_be_at_checked(&mut self, value: f64, offset: usize) -> Option<usize>
Tries to put f64 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_f64_be_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f64_be_at_checked(0x1234 as f64, 2).is_some());
assert!(slice.put_f64_be_at_checked(0x1234 as f64, 30).is_none()); // Out of boundsSourcefn try_put_f64_be_at(
&mut self,
value: f64,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_f64_be_at( &mut self, value: f64, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put f64 value in big-endian byte order to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_f64_be_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f64_be_at(0x1234 as f64, 2).is_ok());
let err = slice.try_put_f64_be_at(0x1234 as f64, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_f64_ne_at(&mut self, value: f64, offset: usize) -> usize
fn put_f64_ne_at(&mut self, value: f64, offset: usize) -> usize
Puts f64 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<f64>() for this type).
§Panics
Panics if offset >= self.mutable() or if offset + size_of::<T>() > self.mutable().
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f64_ne_at(0x1234 as f64, 2);
assert_eq!(written, size_of::<f64>());
// Value is written in native-endian format starting at offset 2Sourcefn put_f64_ne_at_checked(&mut self, value: f64, offset: usize) -> Option<usize>
fn put_f64_ne_at_checked(&mut self, value: f64, offset: usize) -> Option<usize>
Tries to put f64 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_f64_ne_at.
Returns Some(bytes_written) on success, or None if the offset is out of bounds
or there’s insufficient space for the value.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f64_ne_at_checked(0x1234 as f64, 2).is_some());
assert!(slice.put_f64_ne_at_checked(0x1234 as f64, 30).is_none()); // Out of boundsSourcefn try_put_f64_ne_at(
&mut self,
value: f64,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_f64_ne_at( &mut self, value: f64, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put f64 value in native-endian byte order to the buffer at the specified offset without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_f64_ne_at.
Returns Ok(bytes_written) on success, or Err(TryWriteAtError) with detailed
error information if the offset is out of bounds or there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f64_ne_at(0x1234 as f64, 2).is_ok());
let err = slice.try_put_f64_ne_at(0x1234 as f64, 30).unwrap_err();
// err contains detailed information about what went wrongSourcefn put_f64_le(&mut self, value: f64) -> usize
fn put_f64_le(&mut self, value: f64) -> usize
Puts f64 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<f64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f64_le(0x1234 as f64);
assert_eq!(written, size_of::<f64>());
// Value is written in little-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_f64_le_checked(&mut self, value: f64) -> Option<usize>
fn put_f64_le_checked(&mut self, value: f64) -> Option<usize>
Tries to put f64 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_f64_le.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f64_le_checked(0x1234 as f64).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_f64_le_checked(0x1234 as f64).is_none()); // Not enough spaceSourcefn try_put_f64_le(&mut self, value: f64) -> Result<usize, TryWriteError>
fn try_put_f64_le(&mut self, value: f64) -> Result<usize, TryWriteError>
Tries to put f64 value in little-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_f64_le.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f64_le(0x1234 as f64).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_f64_le(0x1234 as f64).unwrap_err();
// err contains information about required vs available spaceSourcefn put_f64_be(&mut self, value: f64) -> usize
fn put_f64_be(&mut self, value: f64) -> usize
Puts a f64 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always size_of::<f64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f64_be(0x1234 as f64);
assert_eq!(written, size_of::<f64>());
// Value is written in big-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_f64_be_checked(&mut self, value: f64) -> Option<usize>
fn put_f64_be_checked(&mut self, value: f64) -> Option<usize>
Tries to put f64 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_f64_be.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f64_be_checked(0x1234 as f64).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_f64_be_checked(0x1234 as f64).is_none()); // Not enough spaceSourcefn try_put_f64_be(&mut self, value: f64) -> Result<usize, TryWriteError>
fn try_put_f64_be(&mut self, value: f64) -> Result<usize, TryWriteError>
Tries to put f64 value in big-endian byte order to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_f64_be.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f64_be(0x1234 as f64).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_f64_be(0x1234 as f64).unwrap_err();
// err contains information about required vs available spaceSourcefn put_f64_ne(&mut self, value: f64) -> usize
fn put_f64_ne(&mut self, value: f64) -> usize
Puts f64 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness (little-endian on x86/x64, big-endian on some embedded platforms).
Returns the number of bytes written (always size_of::<f64>() for this type).
§Panics
Panics if the buffer has insufficient space to hold the value.
Use the *_checked or try_* variants for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_f64_ne(0x1234 as f64);
assert_eq!(written, size_of::<f64>());
// Value is written in native-endian format at the beginning
assert_eq!(slice.mutable(), 24);Sourcefn put_f64_ne_checked(&mut self, value: f64) -> Option<usize>
fn put_f64_ne_checked(&mut self, value: f64) -> Option<usize>
Tries to put f64 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_f64_ne.
Returns Some(bytes_written) on success, or None if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.put_f64_ne_checked(0x1234 as f64).is_some());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
assert!(small_slice.put_f64_ne_checked(0x1234 as f64).is_none()); // Not enough spaceSourcefn try_put_f64_ne(&mut self, value: f64) -> Result<usize, TryWriteError>
fn try_put_f64_ne(&mut self, value: f64) -> Result<usize, TryWriteError>
Tries to put f64 value in native-endian byte order to the beginning of the buffer without advancing the internal cursor.
The byte order depends on the target platform’s endianness.
This is the non-panicking version of put_f64_ne.
Returns Ok(bytes_written) on success, or Err(TryWriteError) with detailed
error information if there’s insufficient space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_f64_ne(0x1234 as f64).is_ok());
assert_eq!(slice.mutable(), 24);
let mut small_buf = [0u8; 1];
let mut small_slice = &mut small_buf[..];
let err = small_slice.try_put_f64_ne(0x1234 as f64).unwrap_err();
// err contains information about required vs available spaceSourcefn put_u8(&mut self, value: u8) -> usize
fn put_u8(&mut self, value: u8) -> usize
Puts u8 value to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always 1 for this type).
§Panics
Panics if the buffer has no space available.
Use put_u8_checked for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
let written = slice.put_u8(0xFF);
assert_eq!(written, 1);
assert_eq!(buf[0], 0xFF);Sourcefn put_u8_checked(&mut self, value: u8) -> Option<usize>
fn put_u8_checked(&mut self, value: u8) -> Option<usize>
Tries to put u8 value to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u8.
Returns Some(1) on success, or None if the buffer has no space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 1];
let mut slice = &mut buf[..];
assert_eq!(slice.put_u8_checked(0xFF), Some(1));
let mut empty = &mut [][..];
assert_eq!(empty.put_u8_checked(0xFF), None);Sourcefn put_i8(&mut self, value: i8) -> usize
fn put_i8(&mut self, value: i8) -> usize
Puts i8 value to the beginning of the buffer without advancing the internal cursor.
Returns the number of bytes written (always 1 for this type).
§Panics
Panics if the buffer has no space available.
Use put_i8_checked for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
let written = slice.put_i8(-42);
assert_eq!(written, 1);
assert_eq!(buf[0], 214); // -42 as u8 isSourcefn put_i8_checked(&mut self, value: i8) -> Option<usize>
fn put_i8_checked(&mut self, value: i8) -> Option<usize>
Tries to put i8 value to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i8.
Returns Some(1) on success, or None if the buffer has no space.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 1];
let mut slice = &mut buf[..];
assert_eq!(slice.put_i8_checked(-42), Some(1));
let mut empty = &mut [][..];
assert_eq!(empty.put_i8_checked(-42), None);Sourcefn put_u8_at(&mut self, value: u8, offset: usize) -> usize
fn put_u8_at(&mut self, value: u8, offset: usize) -> usize
Puts u8 value to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always 1 for this type).
§Panics
Panics if offset >= self.mutable().
Use put_u8_at_checked for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_u8_at(0xFF, 5);
assert_eq!(written, 1);
assert_eq!(buf[5], 0xFF);Sourcefn put_u8_at_checked(&mut self, value: u8, offset: usize) -> Option<usize>
fn put_u8_at_checked(&mut self, value: u8, offset: usize) -> Option<usize>
Tries to put u8 value to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u8_at.
Returns Some(1) on success, or None if the offset is out of bounds.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert_eq!(slice.put_u8_at_checked(0xFF, 5), Some(1));
let err = slice.put_u8_at_checked(0xFF, 30);
assert_eq!(err, None); // Offset out of boundsSourcefn put_i8_at(&mut self, value: i8, offset: usize) -> usize
fn put_i8_at(&mut self, value: i8, offset: usize) -> usize
Puts i8 value to the buffer at the specified offset without advancing the internal cursor.
Returns the number of bytes written (always 1 for this type).
§Panics
Panics if offset >= self.mutable().
Use put_i8_at_checked for non-panicking writes.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
let written = slice.put_i8_at(-42, 5);
assert_eq!(written, 1);
assert_eq!(buf[5], 214); // -42 as u8 is 214Sourcefn put_i8_at_checked(&mut self, value: i8, offset: usize) -> Option<usize>
fn put_i8_at_checked(&mut self, value: i8, offset: usize) -> Option<usize>
Tries to put i8 value to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i8_at.
Returns Some(1) on success, or None if the offset is out of bounds.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert_eq!(slice.put_i8_at_checked(-42, 5), Some(1));
let err = slice.put_i8_at_checked(-42, 30);
assert_eq!(err, None); // Offset out of boundsSourcefn try_put_u8(&mut self, value: u8) -> Result<usize, TryWriteError>
fn try_put_u8(&mut self, value: u8) -> Result<usize, TryWriteError>
Tries to put u8 value to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_u8 that
returns detailed error information on failure.
Returns Ok(1) on success, or Err(TryWriteError) with details about
the available space if the buffer is full.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
assert!(slice.try_put_u8(0xFF).is_ok());
let mut empty = &mut [][..];
let err = empty.try_put_u8(0xFF).unwrap_err();
// err contains details about requested vs available spaceSourcefn try_put_i8(&mut self, value: i8) -> Result<usize, TryWriteError>
fn try_put_i8(&mut self, value: i8) -> Result<usize, TryWriteError>
Tries to put i8 value to the beginning of the buffer without advancing the internal cursor.
This is the non-panicking version of put_i8 that
returns detailed error information on failure.
Returns Ok(1) on success, or Err(TryWriteError) with details about
the available space if the buffer is full.
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 5];
let mut slice = &mut buf[..];
assert!(slice.try_put_i8(-42).is_ok());
let mut empty = &mut [][..];
let err = empty.try_put_i8(-42).unwrap_err();
// err contains details about requested vs available spaceSourcefn try_put_u8_at(
&mut self,
value: u8,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_u8_at( &mut self, value: u8, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put u8 value to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_u8_at that
returns detailed error information on failure.
Returns Ok(1) on success, or Err(TryWriteAtError) with details about
what went wrong (out of bounds offset, etc.).
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_u8_at(0xFF, 5).is_ok());
let err = slice.try_put_u8_at(0xFF, 30).unwrap_err();
// err contains detailed information about the failureSourcefn try_put_i8_at(
&mut self,
value: i8,
offset: usize,
) -> Result<usize, TryWriteAtError>
fn try_put_i8_at( &mut self, value: i8, offset: usize, ) -> Result<usize, TryWriteAtError>
Tries to put i8 value to the buffer at the specified offset without advancing the internal cursor.
This is the non-panicking version of put_i8_at that
returns detailed error information on failure.
Returns Ok(1) on success, or Err(TryWriteAtError) with details about
what went wrong (out of bounds offset, etc.).
§Examples
use bufkit::BufMut;
let mut buf = [0u8; 24];
let mut slice = &mut buf[..];
assert!(slice.try_put_i8_at(-42, 5).is_ok());
let err = slice.try_put_i8_at(-42, 30).unwrap_err();
// err contains detailed information about the failure