Trait positioned_io::WriteBytesExt [] [src]

pub trait WriteBytesExt: WriteAt {
    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<()> { ... }
}

Extends WriteAt with methods for writing numbers at offsets.

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

Examples

Write an integer to the middle of a byte array:

use positioned_io::WriteBytesExt;

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

Provided Methods

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

Writes an unsigned 8-bit integer to an offset.

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

Writes a signed 8-bit integer to an offset.

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

Writes an unsigned 16-bit integer to an offset.

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

Writes a signed 16-bit integer to an offset.

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

Writes an unsigned 32-bit integer to an offset.

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

Writes a signed 32-bit integer to an offset.

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

Writes an unsigned 64-bit integer to an offset.

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

Writes a signed 64-bit integer to an offset.

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

Writes an unsigned nbytes-bit integer to an offset.

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

Writes a signed nbytes-bit integer to an offset.

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

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

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

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

Implementors