[][src]Trait byteio::WriteBytesExt

pub trait WriteBytesExt: WriteBytes {
    fn write_u8(&mut self, n: u8) { ... }
fn try_write_u8(&mut self, n: u8) -> Result<()> { ... }
fn write_i8(&mut self, n: i8) { ... }
fn try_write_i8(&mut self, n: i8) -> Result<()> { ... }
fn write_u16_le(&mut self, n: u16) { ... }
fn write_u16_be(&mut self, n: u16) { ... }
fn try_write_u16_le(&mut self, n: u16) -> Result<()> { ... }
fn try_write_u16_be(&mut self, n: u16) -> Result<()> { ... }
fn write_i16_le(&mut self, n: i16) { ... }
fn write_i16_be(&mut self, n: i16) { ... }
fn try_write_i16_le(&mut self, n: i16) -> Result<()> { ... }
fn try_write_i16_be(&mut self, n: i16) -> Result<()> { ... }
fn write_u32_le(&mut self, n: u32) { ... }
fn write_u32_be(&mut self, n: u32) { ... }
fn try_write_u32_le(&mut self, n: u32) -> Result<()> { ... }
fn try_write_u32_be(&mut self, n: u32) -> Result<()> { ... }
fn write_i32_le(&mut self, n: i32) { ... }
fn write_i32_be(&mut self, n: i32) { ... }
fn try_write_i32_le(&mut self, n: i32) -> Result<()> { ... }
fn try_write_i32_be(&mut self, n: i32) -> Result<()> { ... }
fn write_u64_le(&mut self, n: u64) { ... }
fn write_u64_be(&mut self, n: u64) { ... }
fn try_write_u64_le(&mut self, n: u64) -> Result<()> { ... }
fn try_write_u64_be(&mut self, n: u64) -> Result<()> { ... }
fn write_i64_le(&mut self, n: i64) { ... }
fn write_i64_be(&mut self, n: i64) { ... }
fn try_write_i64_le(&mut self, n: i64) -> Result<()> { ... }
fn try_write_i64_be(&mut self, n: i64) -> Result<()> { ... }
fn write_u128_le(&mut self, n: u128) { ... }
fn write_u128_be(&mut self, n: u128) { ... }
fn try_write_u128_le(&mut self, n: u128) -> Result<()> { ... }
fn try_write_u128_be(&mut self, n: u128) -> Result<()> { ... }
fn write_i128_le(&mut self, n: i128) { ... }
fn write_i128_be(&mut self, n: i128) { ... }
fn try_write_i128_le(&mut self, n: i128) -> Result<()> { ... }
fn try_write_i128_be(&mut self, n: i128) -> Result<()> { ... }
fn write_f32_le(&mut self, n: f32) { ... }
fn write_f32_be(&mut self, n: f32) { ... }
fn try_write_f32_le(&mut self, n: f32) -> Result<()> { ... }
fn try_write_f32_be(&mut self, n: f32) -> Result<()> { ... }
fn write_f64_le(&mut self, n: f64) { ... }
fn write_f64_be(&mut self, n: f64) { ... }
fn try_write_f64_le(&mut self, n: f64) -> Result<()> { ... }
fn try_write_f64_be(&mut self, n: f64) -> Result<()> { ... } }

Extends WriteBytes with functions for writing numbers.

Examples

Write a u16 into a buffer using native endianness:

use byteio::WriteBytesExt;

fn main() {
    let mut buf = [0; 2];

    {
        let mut buf: &mut [u8] = &mut buf;

        #[cfg(target_endian = "little")]
        buf.write_u16_le(256);
        #[cfg(target_endian = "big")]
        buf.write_u16_be(256);

        assert!(buf.is_empty());
    }
}

Provided methods

fn write_u8(&mut self, n: u8)

Writes a u8 into the underlying buffer.

Panics

Panics if there are not enough bytes in self.

fn try_write_u8(&mut self, n: u8) -> Result<()>

Attempts to write a u8 into the underlying buffer.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn write_i8(&mut self, n: i8)

Writes an i8 into the underlying buffer.

Panics

Panics if there are not enough bytes in self.

fn try_write_i8(&mut self, n: i8) -> Result<()>

Attempts to write an i8 into the underlying buffer.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn write_u16_le(&mut self, n: u16)

Writes a u16 into the underlying buffer in little endian byte order.

Panics

Panics if there are not enough bytes in self.

fn write_u16_be(&mut self, n: u16)

Writes a u16 into the underlying buffer in big endian byte order.

Panics

Panics if there are not enough bytes in self.

fn try_write_u16_le(&mut self, n: u16) -> Result<()>

Attempts to write a u16 into the underlying buffer in little endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn try_write_u16_be(&mut self, n: u16) -> Result<()>

Attempts to write a u16 into the underlying buffer in big endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn write_i16_le(&mut self, n: i16)

Writes an i16 into the underlying buffer in little endian byte order.

Panics

Panics if there are not enough bytes in self.

fn write_i16_be(&mut self, n: i16)

Writes an i16 into the underlying buffer in big endian byte order.

Panics

Panics if there are not enough bytes in self.

fn try_write_i16_le(&mut self, n: i16) -> Result<()>

Attempts to write an i16 into the underlying buffer in little endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn try_write_i16_be(&mut self, n: i16) -> Result<()>

Attempts to write an i16 into the underlying buffer in big endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn write_u32_le(&mut self, n: u32)

Writes a u32 into the underlying buffer in little endian byte order.

Panics

Panics if there are not enough bytes in self.

fn write_u32_be(&mut self, n: u32)

Writes a u32 into the underlying buffer in big endian byte order.

Panics

Panics if there are not enough bytes in self.

fn try_write_u32_le(&mut self, n: u32) -> Result<()>

Attempts to write a u32 into the underlying buffer in little endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn try_write_u32_be(&mut self, n: u32) -> Result<()>

Attempts to write a u32 into the underlying buffer in big endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn write_i32_le(&mut self, n: i32)

Writes an i32 into the underlying buffer in little endian byte order.

Panics

Panics if there are not enough bytes in self.

fn write_i32_be(&mut self, n: i32)

Writes an i32 into the underlying buffer in big endian byte order.

Panics

Panics if there are not enough bytes in self.

fn try_write_i32_le(&mut self, n: i32) -> Result<()>

Attempts to write an i32 into the underlying buffer in little endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn try_write_i32_be(&mut self, n: i32) -> Result<()>

Attempts to write an i32 into the underlying buffer in big endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn write_u64_le(&mut self, n: u64)

Writes a u64 into the underlying buffer in little endian byte order.

Panics

Panics if there are not enough bytes in self.

fn write_u64_be(&mut self, n: u64)

Writes a u64 into the underlying buffer in big endian byte order.

Panics

Panics if there are not enough bytes in self.

fn try_write_u64_le(&mut self, n: u64) -> Result<()>

Attempts to write a u64 into the underlying buffer in little endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn try_write_u64_be(&mut self, n: u64) -> Result<()>

Attempts to write a u64 into the underlying buffer in big endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn write_i64_le(&mut self, n: i64)

Writes an i64 into the underlying buffer in little endian byte order.

Panics

Panics if there are not enough bytes in self.

fn write_i64_be(&mut self, n: i64)

Writes an i64 into the underlying buffer in big endian byte order.

Panics

Panics if there are not enough bytes in self.

fn try_write_i64_le(&mut self, n: i64) -> Result<()>

Attempts to write an i64 into the underlying buffer in little endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn try_write_i64_be(&mut self, n: i64) -> Result<()>

Attempts to write an i64 into the underlying buffer in big endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn write_u128_le(&mut self, n: u128)

Writes a u128 into the underlying buffer in little endian byte order.

Panics

Panics if there are not enough bytes in self.

fn write_u128_be(&mut self, n: u128)

Writes a u128 into the underlying buffer in big endian byte order.

Panics

Panics if there are not enough bytes in self.

fn try_write_u128_le(&mut self, n: u128) -> Result<()>

Attempts to write a u128 into the underlying buffer in little endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn try_write_u128_be(&mut self, n: u128) -> Result<()>

Attempts to write a u128 into the underlying buffer in big endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn write_i128_le(&mut self, n: i128)

Writes an i128 into the underlying buffer in little endian byte order.

Panics

Panics if there are not enough bytes in self.

fn write_i128_be(&mut self, n: i128)

Writes an i128 into the underlying buffer in big endian byte order.

Panics

Panics if there are not enough bytes in self.

fn try_write_i128_le(&mut self, n: i128) -> Result<()>

Attempts to write an i128 into the underlying buffer in little endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn try_write_i128_be(&mut self, n: i128) -> Result<()>

Attempts to write an i128 into the underlying buffer in big endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn write_f32_le(&mut self, n: f32)

Writes an IEEE754 f32 into the underlying buffer in little endian byte order.

Panics

Panics if there are not enough bytes in self.

fn write_f32_be(&mut self, n: f32)

Writes an IEEE754 f32 into the underlying buffer in big endian byte order.

Panics

Panics if there are not enough bytes in self.

fn try_write_f32_le(&mut self, n: f32) -> Result<()>

Attempts to write an IEEE754 f32 into the underlying buffer.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn try_write_f32_be(&mut self, n: f32) -> Result<()>

Attempts to write an IEEE754 f32 into the underlying buffer in big endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn write_f64_le(&mut self, n: f64)

Writes an IEEE754 f64 into the underlying buffer in little endian byte order.

Panics

Panics if there are not enough bytes in self.

fn write_f64_be(&mut self, n: f64)

Writes an IEEE754 f64 into the underlying buffer in big endian byte order.

Panics

Panics if there are not enough bytes in self.

fn try_write_f64_le(&mut self, n: f64) -> Result<()>

Attempts to write an IEEE754 f64 into the underlying buffer.

If there are not enough bytes in self this function will return Error::EndOfStream.

fn try_write_f64_be(&mut self, n: f64) -> Result<()>

Attempts to write an IEEE754 f64 into the underlying buffer in big endian byte order.

If there are not enough bytes in self this function will return Error::EndOfStream.

Loading content...

Implementors

impl<W: WriteBytes> WriteBytesExt for W[src]

Loading content...