Trait pw_stream::ReadInteger
source · pub trait ReadInteger {
Show 20 methods
// Required methods
fn read_i8_le(&mut self) -> Result<i8>;
fn read_u8_le(&mut self) -> Result<u8>;
fn read_i8_be(&mut self) -> Result<i8>;
fn read_u8_be(&mut self) -> Result<u8>;
fn read_i16_le(&mut self) -> Result<i16>;
fn read_u16_le(&mut self) -> Result<u16>;
fn read_i16_be(&mut self) -> Result<i16>;
fn read_u16_be(&mut self) -> Result<u16>;
fn read_i32_le(&mut self) -> Result<i32>;
fn read_u32_le(&mut self) -> Result<u32>;
fn read_i32_be(&mut self) -> Result<i32>;
fn read_u32_be(&mut self) -> Result<u32>;
fn read_i64_le(&mut self) -> Result<i64>;
fn read_u64_le(&mut self) -> Result<u64>;
fn read_i64_be(&mut self) -> Result<i64>;
fn read_u64_be(&mut self) -> Result<u64>;
fn read_i128_le(&mut self) -> Result<i128>;
fn read_u128_le(&mut self) -> Result<u128>;
fn read_i128_be(&mut self) -> Result<i128>;
fn read_u128_be(&mut self) -> Result<u128>;
}
Expand description
A trait for reading integers from a stream.
Allows reading signed and unsigned integers from 8 to 128 bits in either big or little endian byte order.
§Example
use pw_stream::{Cursor, ReadInteger};
let mut cursor = Cursor::new([0x3, 0x4, 0x5, 0x80]);
let value = cursor.read_u32_le().unwrap();
assert_eq!(value, 0x8005_0403);
§Future Work
In order to allow for optimized non-generic implementations, there is
no blanket implementation over the crate::Read
trait. An IntegerReader
adapter could be written to allow this functionality.
Required Methods§
sourcefn read_i8_le(&mut self) -> Result<i8>
fn read_i8_le(&mut self) -> Result<i8>
Reads a little-endian i8 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_u8_le(&mut self) -> Result<u8>
fn read_u8_le(&mut self) -> Result<u8>
Reads a little-endian u8 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_i8_be(&mut self) -> Result<i8>
fn read_i8_be(&mut self) -> Result<i8>
Reads a big-endian i8 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_u8_be(&mut self) -> Result<u8>
fn read_u8_be(&mut self) -> Result<u8>
Reads a big-endian u8 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_i16_le(&mut self) -> Result<i16>
fn read_i16_le(&mut self) -> Result<i16>
Reads a little-endian i16 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_u16_le(&mut self) -> Result<u16>
fn read_u16_le(&mut self) -> Result<u16>
Reads a little-endian u16 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_i16_be(&mut self) -> Result<i16>
fn read_i16_be(&mut self) -> Result<i16>
Reads a big-endian i16 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_u16_be(&mut self) -> Result<u16>
fn read_u16_be(&mut self) -> Result<u16>
Reads a big-endian u16 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_i32_le(&mut self) -> Result<i32>
fn read_i32_le(&mut self) -> Result<i32>
Reads a little-endian i32 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_u32_le(&mut self) -> Result<u32>
fn read_u32_le(&mut self) -> Result<u32>
Reads a little-endian u32 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_i32_be(&mut self) -> Result<i32>
fn read_i32_be(&mut self) -> Result<i32>
Reads a big-endian i32 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_u32_be(&mut self) -> Result<u32>
fn read_u32_be(&mut self) -> Result<u32>
Reads a big-endian u32 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_i64_le(&mut self) -> Result<i64>
fn read_i64_le(&mut self) -> Result<i64>
Reads a little-endian i64 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_u64_le(&mut self) -> Result<u64>
fn read_u64_le(&mut self) -> Result<u64>
Reads a little-endian u64 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_i64_be(&mut self) -> Result<i64>
fn read_i64_be(&mut self) -> Result<i64>
Reads a big-endian i64 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_u64_be(&mut self) -> Result<u64>
fn read_u64_be(&mut self) -> Result<u64>
Reads a big-endian u64 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_i128_le(&mut self) -> Result<i128>
fn read_i128_le(&mut self) -> Result<i128>
Reads a little-endian i128 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_u128_le(&mut self) -> Result<u128>
fn read_u128_le(&mut self) -> Result<u128>
Reads a little-endian u128 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_i128_be(&mut self) -> Result<i128>
fn read_i128_be(&mut self) -> Result<i128>
Reads a big-endian i128 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.
sourcefn read_u128_be(&mut self) -> Result<u128>
fn read_u128_be(&mut self) -> Result<u128>
Reads a big-endian u128 returning it’s value or an Error.
Errors that may be returned are dependant on the underlying implementation.