Trait WriteBytesAtExt

Source
pub trait WriteBytesAtExt: WriteAt {
    // Provided methods
    fn write_u8_at(&mut self, pos: u64, n: u8) -> Result<()> { ... }
    fn write_i8_at(&mut self, pos: u64, n: i8) -> Result<()> { ... }
    fn write_u16_at<T: ByteOrder>(&mut self, pos: u64, n: u16) -> Result<()> { ... }
    fn write_i16_at<T: ByteOrder>(&mut self, pos: u64, n: i16) -> Result<()> { ... }
    fn write_u32_at<T: ByteOrder>(&mut self, pos: u64, n: u32) -> Result<()> { ... }
    fn write_i32_at<T: ByteOrder>(&mut self, pos: u64, n: i32) -> Result<()> { ... }
    fn write_u64_at<T: ByteOrder>(&mut self, pos: u64, n: u64) -> Result<()> { ... }
    fn write_i64_at<T: ByteOrder>(&mut self, pos: u64, n: i64) -> Result<()> { ... }
    fn write_uint_at<T: ByteOrder>(
        &mut self,
        pos: u64,
        n: u64,
        nbytes: usize,
    ) -> Result<()> { ... }
    fn write_int_at<T: ByteOrder>(
        &mut self,
        pos: u64,
        n: i64,
        nbytes: usize,
    ) -> Result<()> { ... }
    fn write_f32_at<T: ByteOrder>(&mut self, pos: u64, n: f32) -> Result<()> { ... }
    fn write_f64_at<T: ByteOrder>(&mut self, pos: u64, n: f64) -> Result<()> { ... }
}
Expand description

Extends WriteAt with methods for writing numbers at offsets.

For most of these methods, you need to explicitly add a ByteOrder type parameter. Similar to byteorder::WriteBytesExt.

§Examples

Write an integer to the middle of a byte array:

use byteorder::BigEndian;
use positioned_io2::WriteBytesAtExt;

let mut buf = [0; 6];
buf.as_mut().write_u16_at::<BigEndian>(2, 300)?;
assert_eq!(buf, [0, 0, 1, 44, 0, 0]);

Provided Methods§

Source

fn write_u8_at(&mut self, pos: u64, n: u8) -> Result<()>

Writes an unsigned 8-bit integer to an offset.

Source

fn write_i8_at(&mut self, pos: u64, n: i8) -> Result<()>

Writes a signed 8-bit integer to an offset.

Source

fn write_u16_at<T: ByteOrder>(&mut self, pos: u64, n: u16) -> Result<()>

Writes an unsigned 16-bit integer to an offset.

Source

fn write_i16_at<T: ByteOrder>(&mut self, pos: u64, n: i16) -> Result<()>

Writes a signed 16-bit integer to an offset.

Source

fn write_u32_at<T: ByteOrder>(&mut self, pos: u64, n: u32) -> Result<()>

Writes an unsigned 32-bit integer to an offset.

Source

fn write_i32_at<T: ByteOrder>(&mut self, pos: u64, n: i32) -> Result<()>

Writes a signed 32-bit integer to an offset.

Source

fn write_u64_at<T: ByteOrder>(&mut self, pos: u64, n: u64) -> Result<()>

Writes an unsigned 64-bit integer to an offset.

Source

fn write_i64_at<T: ByteOrder>(&mut self, pos: u64, n: i64) -> Result<()>

Writes a signed 64-bit integer to an offset.

Source

fn write_uint_at<T: ByteOrder>( &mut self, pos: u64, n: u64, nbytes: usize, ) -> Result<()>

Writes an unsigned nbytes-bit integer to an offset.

Source

fn write_int_at<T: ByteOrder>( &mut self, pos: u64, n: i64, nbytes: usize, ) -> Result<()>

Writes a signed nbytes-bit integer to an offset.

Source

fn write_f32_at<T: ByteOrder>(&mut self, pos: u64, n: f32) -> Result<()>

Writes a single-precision floating point number to an offset.

Source

fn write_f64_at<T: ByteOrder>(&mut self, pos: u64, n: f64) -> Result<()>

Writes a double-precision floating point number to an offset.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§