Trait byteorder::WriteBytesExt [] [src]

pub trait WriteBytesExt: Write {
    fn write_u8(&mut self, n: u8) -> Result<()> { ... }
fn write_i8(&mut self, n: i8) -> Result<()> { ... }
fn write_u16<T: ByteOrder>(&mut self, n: u16) -> Result<()> { ... }
fn write_i16<T: ByteOrder>(&mut self, n: i16) -> Result<()> { ... }
fn write_u24<T: ByteOrder>(&mut self, n: u32) -> Result<()> { ... }
fn write_i24<T: ByteOrder>(&mut self, n: i32) -> Result<()> { ... }
fn write_u32<T: ByteOrder>(&mut self, n: u32) -> Result<()> { ... }
fn write_i32<T: ByteOrder>(&mut self, n: i32) -> Result<()> { ... }
fn write_u48<T: ByteOrder>(&mut self, n: u64) -> Result<()> { ... }
fn write_i48<T: ByteOrder>(&mut self, n: i64) -> Result<()> { ... }
fn write_u64<T: ByteOrder>(&mut self, n: u64) -> Result<()> { ... }
fn write_i64<T: ByteOrder>(&mut self, n: i64) -> Result<()> { ... }
fn write_uint<T: ByteOrder>(&mut self, n: u64, nbytes: usize) -> Result<()> { ... }
fn write_int<T: ByteOrder>(&mut self, n: i64, nbytes: usize) -> Result<()> { ... }
fn write_f32<T: ByteOrder>(&mut self, n: f32) -> Result<()> { ... }
fn write_f64<T: ByteOrder>(&mut self, n: f64) -> Result<()> { ... } }

Extends Write with methods for writing numbers. (For std::io.)

Most of the methods defined here have an unconstrained type parameter that must be explicitly instantiated. Typically, it is instantiated with either the BigEndian or LittleEndian types defined in this crate.

Examples

Write unsigned 16 bit big-endian integers to a Write:

use byteorder::{BigEndian, WriteBytesExt};

let mut wtr = vec![];
wtr.write_u16::<BigEndian>(517).unwrap();
wtr.write_u16::<BigEndian>(768).unwrap();
assert_eq!(wtr, vec![2, 5, 3, 0]);

Provided Methods

Writes an unsigned 8 bit integer to the underlying writer.

Note that since this writes a single byte, no byte order conversions are used. It is included for completeness.

Errors

This method returns the same errors as Write::write_all.

Writes a signed 8 bit integer to the underlying writer.

Note that since this writes a single byte, no byte order conversions are used. It is included for completeness.

Errors

This method returns the same errors as Write::write_all.

Writes an unsigned 16 bit integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Writes a signed 16 bit integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Writes an unsigned 24 bit integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Writes a signed 24 bit integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Writes an unsigned 32 bit integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Writes a signed 32 bit integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Writes an unsigned 48 bit integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Writes a signed 48 bit integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Writes an unsigned 64 bit integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Writes a signed 64 bit integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Writes an unsigned n-bytes integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Panics

If the given integer is not representable in the given number of bytes, this method panics. If nbytes > 8, this method panics.

Writes a signed n-bytes integer to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Panics

If the given integer is not representable in the given number of bytes, this method panics. If nbytes > 8, this method panics.

Writes a IEEE754 single-precision (4 bytes) floating point number to the underlying writer.

Errors

This method returns the same errors as Write::write_all.

Writes a IEEE754 double-precision (8 bytes) floating point number to the underlying writer.

Implementors