Trait pw_stream::WriteInteger
source · pub trait WriteInteger {
Show 20 methods
// Required methods
fn write_i8_le(&mut self, value: &i8) -> Result<()>;
fn write_u8_le(&mut self, value: &u8) -> Result<()>;
fn write_i8_be(&mut self, value: &i8) -> Result<()>;
fn write_u8_be(&mut self, value: &u8) -> Result<()>;
fn write_i16_le(&mut self, value: &i16) -> Result<()>;
fn write_u16_le(&mut self, value: &u16) -> Result<()>;
fn write_i16_be(&mut self, value: &i16) -> Result<()>;
fn write_u16_be(&mut self, value: &u16) -> Result<()>;
fn write_i32_le(&mut self, value: &i32) -> Result<()>;
fn write_u32_le(&mut self, value: &u32) -> Result<()>;
fn write_i32_be(&mut self, value: &i32) -> Result<()>;
fn write_u32_be(&mut self, value: &u32) -> Result<()>;
fn write_i64_le(&mut self, value: &i64) -> Result<()>;
fn write_u64_le(&mut self, value: &u64) -> Result<()>;
fn write_i64_be(&mut self, value: &i64) -> Result<()>;
fn write_u64_be(&mut self, value: &u64) -> Result<()>;
fn write_i128_le(&mut self, value: &i128) -> Result<()>;
fn write_u128_le(&mut self, value: &u128) -> Result<()>;
fn write_i128_be(&mut self, value: &i128) -> Result<()>;
fn write_u128_be(&mut self, value: &u128) -> Result<()>;
}
Expand description
A trait for writing integers toa stream.
Allows writing signed and unsigned integers from 8 to 128 bits in either big or little endian byte order.
§Example
use pw_stream::{Cursor, WriteInteger};
let mut cursor = Cursor::new([0u8; 8]);
cursor.write_u32_le(&0x8005_0403).unwrap();
let buffer = cursor.into_inner();
assert_eq!(buffer, [0x3, 0x4, 0x5, 0x80, 0x0, 0x0, 0x0, 0x0]);
§Future Work
In order to allow for optimized non-generic implementations, there is
no blanket implementation over the crate::Write
trait. An IntegerWriter
adapter could be written to allow this functionality.
Required Methods§
sourcefn write_i8_le(&mut self, value: &i8) -> Result<()>
fn write_i8_le(&mut self, value: &i8) -> Result<()>
Writes a little-endian i8.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_u8_le(&mut self, value: &u8) -> Result<()>
fn write_u8_le(&mut self, value: &u8) -> Result<()>
Writes a little-endian u8.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_i8_be(&mut self, value: &i8) -> Result<()>
fn write_i8_be(&mut self, value: &i8) -> Result<()>
Writes a big-endian i8.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_u8_be(&mut self, value: &u8) -> Result<()>
fn write_u8_be(&mut self, value: &u8) -> Result<()>
Writes a big-endian u8.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_i16_le(&mut self, value: &i16) -> Result<()>
fn write_i16_le(&mut self, value: &i16) -> Result<()>
Writes a little-endian i16.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_u16_le(&mut self, value: &u16) -> Result<()>
fn write_u16_le(&mut self, value: &u16) -> Result<()>
Writes a little-endian u16.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_i16_be(&mut self, value: &i16) -> Result<()>
fn write_i16_be(&mut self, value: &i16) -> Result<()>
Writes a big-endian i16.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_u16_be(&mut self, value: &u16) -> Result<()>
fn write_u16_be(&mut self, value: &u16) -> Result<()>
Writes a big-endian u16.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_i32_le(&mut self, value: &i32) -> Result<()>
fn write_i32_le(&mut self, value: &i32) -> Result<()>
Writes a little-endian i32.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_u32_le(&mut self, value: &u32) -> Result<()>
fn write_u32_le(&mut self, value: &u32) -> Result<()>
Writes a little-endian u32.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_i32_be(&mut self, value: &i32) -> Result<()>
fn write_i32_be(&mut self, value: &i32) -> Result<()>
Writes a big-endian i32.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_u32_be(&mut self, value: &u32) -> Result<()>
fn write_u32_be(&mut self, value: &u32) -> Result<()>
Writes a big-endian u32.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_i64_le(&mut self, value: &i64) -> Result<()>
fn write_i64_le(&mut self, value: &i64) -> Result<()>
Writes a little-endian i64.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_u64_le(&mut self, value: &u64) -> Result<()>
fn write_u64_le(&mut self, value: &u64) -> Result<()>
Writes a little-endian u64.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_i64_be(&mut self, value: &i64) -> Result<()>
fn write_i64_be(&mut self, value: &i64) -> Result<()>
Writes a big-endian i64.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_u64_be(&mut self, value: &u64) -> Result<()>
fn write_u64_be(&mut self, value: &u64) -> Result<()>
Writes a big-endian u64.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_i128_le(&mut self, value: &i128) -> Result<()>
fn write_i128_le(&mut self, value: &i128) -> Result<()>
Writes a little-endian i128.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_u128_le(&mut self, value: &u128) -> Result<()>
fn write_u128_le(&mut self, value: &u128) -> Result<()>
Writes a little-endian u128.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_i128_be(&mut self, value: &i128) -> Result<()>
fn write_i128_be(&mut self, value: &i128) -> Result<()>
Writes a big-endian i128.
Errors that may be returned are dependant on the underlying implementation.
sourcefn write_u128_be(&mut self, value: &u128) -> Result<()>
fn write_u128_be(&mut self, value: &u128) -> Result<()>
Writes a big-endian u128.
Errors that may be returned are dependant on the underlying implementation.