pub trait Bt {
Show 125 methods
// Required methods
fn remaining(&self) -> usize;
fn chunk(&self) -> &[u8] ⓘ;
fn advance(&mut self, n: usize);
fn advance_chunk(&mut self, n: usize) -> &[u8] ⓘ;
fn into_binary(self) -> Binary ⓘ;
// Provided methods
fn advance_all(&mut self) { ... }
fn peek(&self) -> Option<u8> { ... }
fn has_remaining(&self) -> bool { ... }
fn get_next(&mut self) -> Option<u8> { ... }
fn copy_to_slice(&mut self, dst: &mut [u8]) -> usize { ... }
fn peek_to_slice(&mut self, dst: &mut [u8]) -> usize { ... }
fn get_u8(&mut self) -> u8 { ... }
fn peek_u8(&mut self) -> u8 { ... }
fn try_get_u8(&mut self) -> Result<u8> { ... }
fn get_i8(&mut self) -> i8 { ... }
fn peek_i8(&mut self) -> i8 { ... }
fn try_get_i8(&mut self) -> Result<i8> { ... }
fn get_u16(&mut self) -> u16 { ... }
fn peek_u16(&mut self) -> u16 { ... }
fn try_get_u16(&mut self) -> Result<u16> { ... }
fn get_u16_le(&mut self) -> u16 { ... }
fn peek_u16_le(&mut self) -> u16 { ... }
fn try_get_u16_le(&mut self) -> Result<u16> { ... }
fn get_u16_ne(&mut self) -> u16 { ... }
fn peek_u16_ne(&mut self) -> u16 { ... }
fn try_get_u16_ne(&mut self) -> Result<u16> { ... }
fn get_i16(&mut self) -> i16 { ... }
fn peek_i16(&mut self) -> i16 { ... }
fn try_get_i16(&mut self) -> Result<i16> { ... }
fn get_i16_le(&mut self) -> i16 { ... }
fn peek_i16_le(&mut self) -> i16 { ... }
fn try_get_i16_le(&mut self) -> Result<i16> { ... }
fn get_i16_ne(&mut self) -> i16 { ... }
fn peek_i16_ne(&mut self) -> i16 { ... }
fn try_get_i16_ne(&mut self) -> Result<i16> { ... }
fn get_u32(&mut self) -> u32 { ... }
fn peek_u32(&mut self) -> u32 { ... }
fn try_get_u32(&mut self) -> Result<u32> { ... }
fn get_u32_le(&mut self) -> u32 { ... }
fn peek_u32_le(&mut self) -> u32 { ... }
fn try_get_u32_le(&mut self) -> Result<u32> { ... }
fn get_u32_ne(&mut self) -> u32 { ... }
fn peek_u32_ne(&mut self) -> u32 { ... }
fn try_get_u32_ne(&mut self) -> Result<u32> { ... }
fn get_i32(&mut self) -> i32 { ... }
fn peek_i32(&mut self) -> i32 { ... }
fn try_get_i32(&mut self) -> Result<i32> { ... }
fn get_i32_le(&mut self) -> i32 { ... }
fn peek_i32_le(&mut self) -> i32 { ... }
fn try_get_i32_le(&mut self) -> Result<i32> { ... }
fn get_i32_ne(&mut self) -> i32 { ... }
fn peek_i32_ne(&mut self) -> i32 { ... }
fn try_get_i32_ne(&mut self) -> Result<i32> { ... }
fn get_u64(&mut self) -> u64 { ... }
fn peek_u64(&mut self) -> u64 { ... }
fn try_get_u64(&mut self) -> Result<u64> { ... }
fn get_u64_le(&mut self) -> u64 { ... }
fn peek_u64_le(&mut self) -> u64 { ... }
fn try_get_u64_le(&mut self) -> Result<u64> { ... }
fn get_u64_ne(&mut self) -> u64 { ... }
fn peek_u64_ne(&mut self) -> u64 { ... }
fn try_get_u64_ne(&mut self) -> Result<u64> { ... }
fn get_i64(&mut self) -> i64 { ... }
fn peek_i64(&mut self) -> i64 { ... }
fn try_get_i64(&mut self) -> Result<i64> { ... }
fn get_i64_le(&mut self) -> i64 { ... }
fn peek_i64_le(&mut self) -> i64 { ... }
fn try_get_i64_le(&mut self) -> Result<i64> { ... }
fn get_i64_ne(&mut self) -> i64 { ... }
fn peek_i64_ne(&mut self) -> i64 { ... }
fn try_get_i64_ne(&mut self) -> Result<i64> { ... }
fn get_u128(&mut self) -> u128 { ... }
fn peek_u128(&mut self) -> u128 { ... }
fn try_get_u128(&mut self) -> Result<u128> { ... }
fn get_u128_le(&mut self) -> u128 { ... }
fn peek_u128_le(&mut self) -> u128 { ... }
fn try_get_u128_le(&mut self) -> Result<u128> { ... }
fn get_u128_ne(&mut self) -> u128 { ... }
fn peek_u128_ne(&mut self) -> u128 { ... }
fn try_get_u128_ne(&mut self) -> Result<u128> { ... }
fn get_i128(&mut self) -> i128 { ... }
fn peek_i128(&mut self) -> i128 { ... }
fn try_get_i128(&mut self) -> Result<i128> { ... }
fn get_i128_le(&mut self) -> i128 { ... }
fn peek_i128_le(&mut self) -> i128 { ... }
fn try_get_i128_le(&mut self) -> Result<i128> { ... }
fn get_i128_ne(&mut self) -> i128 { ... }
fn peek_i128_ne(&mut self) -> i128 { ... }
fn try_get_i128_ne(&mut self) -> Result<i128> { ... }
fn get_uint(&mut self, nbytes: usize) -> u64 { ... }
fn peek_uint(&mut self, nbytes: usize) -> u64 { ... }
fn try_get_uint(&mut self, nbytes: usize) -> Result<u64> { ... }
fn get_uint_le(&mut self, nbytes: usize) -> u64 { ... }
fn peek_uint_le(&mut self, nbytes: usize) -> u64 { ... }
fn try_get_uint_le(&mut self, nbytes: usize) -> Result<u64> { ... }
fn get_uint_ne(&mut self, nbytes: usize) -> u64 { ... }
fn peek_uint_ne(&mut self, nbytes: usize) -> u64 { ... }
fn try_get_uint_ne(&mut self, nbytes: usize) -> Result<u64> { ... }
fn get_int(&mut self, nbytes: usize) -> i64 { ... }
fn peek_int(&mut self, nbytes: usize) -> i64 { ... }
fn try_get_int(&mut self, nbytes: usize) -> Result<i64> { ... }
fn get_int_le(&mut self, nbytes: usize) -> i64 { ... }
fn peek_int_le(&mut self, nbytes: usize) -> i64 { ... }
fn try_get_int_le(&mut self, nbytes: usize) -> Result<i64> { ... }
fn get_int_ne(&mut self, nbytes: usize) -> i64 { ... }
fn peek_int_ne(&mut self, nbytes: usize) -> i64 { ... }
fn try_get_int_ne(&mut self, nbytes: usize) -> Result<i64> { ... }
fn get_f32(&mut self) -> f32 { ... }
fn peek_f32(&mut self) -> f32 { ... }
fn try_get_f32(&mut self) -> Result<f32> { ... }
fn get_f32_le(&mut self) -> f32 { ... }
fn peek_f32_le(&mut self) -> f32 { ... }
fn try_get_f32_le(&mut self) -> Result<f32> { ... }
fn get_f32_ne(&mut self) -> f32 { ... }
fn peek_f32_ne(&mut self) -> f32 { ... }
fn try_get_f32_ne(&mut self) -> Result<f32> { ... }
fn get_f64(&mut self) -> f64 { ... }
fn peek_f64(&mut self) -> f64 { ... }
fn try_get_f64(&mut self) -> Result<f64> { ... }
fn get_f64_le(&mut self) -> f64 { ... }
fn peek_f64_le(&mut self) -> f64 { ... }
fn try_get_f64_le(&mut self) -> Result<f64> { ... }
fn get_f64_ne(&mut self) -> f64 { ... }
fn peek_f64_ne(&mut self) -> f64 { ... }
fn try_get_f64_ne(&mut self) -> Result<f64> { ... }
}
Required Methods§
sourcefn advance_chunk(&mut self, n: usize) -> &[u8] ⓘ
fn advance_chunk(&mut self, n: usize) -> &[u8] ⓘ
消耗掉多少字节的数据并返回消耗的数据
sourcefn into_binary(self) -> Binary ⓘ
fn into_binary(self) -> Binary ⓘ
将数据转成Binary
Provided Methods§
sourcefn advance_all(&mut self)
fn advance_all(&mut self)
消耗所有的字节
sourcefn has_remaining(&self) -> bool
fn has_remaining(&self) -> bool
是否还有数据
sourcefn copy_to_slice(&mut self, dst: &mut [u8]) -> usize
fn copy_to_slice(&mut self, dst: &mut [u8]) -> usize
fn peek_to_slice(&mut self, dst: &mut [u8]) -> usize
fn get_u8(&mut self) -> u8
fn peek_u8(&mut self) -> u8
fn try_get_u8(&mut self) -> Result<u8>
fn get_i8(&mut self) -> i8
fn peek_i8(&mut self) -> i8
fn try_get_i8(&mut self) -> Result<i8>
fn peek_u16(&mut self) -> u16
fn try_get_u16(&mut self) -> Result<u16>
sourcefn get_u16_le(&mut self) -> u16
fn get_u16_le(&mut self) -> u16
fn peek_u16_le(&mut self) -> u16
fn try_get_u16_le(&mut self) -> Result<u16>
sourcefn get_u16_ne(&mut self) -> u16
fn get_u16_ne(&mut self) -> u16
Gets an unsigned 16 bit integer from self
in native-endian byte order.
The current position is advanced by 2.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x08\x09 hello",
false => b"\x09\x08 hello",
};
assert_eq!(0x0809, buf.get_u16_ne());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_u16_ne(&mut self) -> u16
fn try_get_u16_ne(&mut self) -> Result<u16>
fn peek_i16(&mut self) -> i16
fn try_get_i16(&mut self) -> Result<i16>
sourcefn get_i16_le(&mut self) -> i16
fn get_i16_le(&mut self) -> i16
fn peek_i16_le(&mut self) -> i16
fn try_get_i16_le(&mut self) -> Result<i16>
sourcefn get_i16_ne(&mut self) -> i16
fn get_i16_ne(&mut self) -> i16
Gets a signed 16 bit integer from self
in native-endian byte order.
The current position is advanced by 2.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x08\x09 hello",
false => b"\x09\x08 hello",
};
assert_eq!(0x0809, buf.get_i16_ne());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_i16_ne(&mut self) -> i16
fn try_get_i16_ne(&mut self) -> Result<i16>
sourcefn get_u32(&mut self) -> u32
fn get_u32(&mut self) -> u32
Gets an unsigned 32 bit integer from self
in the big-endian byte order.
The current position is advanced by 4.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x08\x09\xA0\xA1 hello"[..];
assert_eq!(0x0809A0A1, buf.get_u32());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_u32(&mut self) -> u32
fn try_get_u32(&mut self) -> Result<u32>
sourcefn get_u32_le(&mut self) -> u32
fn get_u32_le(&mut self) -> u32
Gets an unsigned 32 bit integer from self
in the little-endian byte order.
The current position is advanced by 4.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\xA1\xA0\x09\x08 hello"[..];
assert_eq!(0x0809A0A1, buf.get_u32_le());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_u32_le(&mut self) -> u32
fn try_get_u32_le(&mut self) -> Result<u32>
sourcefn get_u32_ne(&mut self) -> u32
fn get_u32_ne(&mut self) -> u32
Gets an unsigned 32 bit integer from self
in native-endian byte order.
The current position is advanced by 4.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x08\x09\xA0\xA1 hello",
false => b"\xA1\xA0\x09\x08 hello",
};
assert_eq!(0x0809A0A1, buf.get_u32_ne());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_u32_ne(&mut self) -> u32
fn try_get_u32_ne(&mut self) -> Result<u32>
fn peek_i32(&mut self) -> i32
fn try_get_i32(&mut self) -> Result<i32>
sourcefn get_i32_le(&mut self) -> i32
fn get_i32_le(&mut self) -> i32
Gets a signed 32 bit integer from self
in little-endian byte order.
The current position is advanced by 4.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\xA1\xA0\x09\x08 hello"[..];
assert_eq!(0x0809A0A1, buf.get_i32_le());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_i32_le(&mut self) -> i32
fn try_get_i32_le(&mut self) -> Result<i32>
sourcefn get_i32_ne(&mut self) -> i32
fn get_i32_ne(&mut self) -> i32
Gets a signed 32 bit integer from self
in native-endian byte order.
The current position is advanced by 4.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x08\x09\xA0\xA1 hello",
false => b"\xA1\xA0\x09\x08 hello",
};
assert_eq!(0x0809A0A1, buf.get_i32_ne());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_i32_ne(&mut self) -> i32
fn try_get_i32_ne(&mut self) -> Result<i32>
sourcefn get_u64(&mut self) -> u64
fn get_u64(&mut self) -> u64
Gets an unsigned 64 bit integer from self
in big-endian byte order.
The current position is advanced by 8.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"[..];
assert_eq!(0x0102030405060708, buf.get_u64());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_u64(&mut self) -> u64
fn try_get_u64(&mut self) -> Result<u64>
sourcefn get_u64_le(&mut self) -> u64
fn get_u64_le(&mut self) -> u64
Gets an unsigned 64 bit integer from self
in little-endian byte order.
The current position is advanced by 8.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];
assert_eq!(0x0102030405060708, buf.get_u64_le());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_u64_le(&mut self) -> u64
fn try_get_u64_le(&mut self) -> Result<u64>
sourcefn get_u64_ne(&mut self) -> u64
fn get_u64_ne(&mut self) -> u64
Gets an unsigned 64 bit integer from self
in native-endian byte order.
The current position is advanced by 8.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x01\x02\x03\x04\x05\x06\x07\x08 hello",
false => b"\x08\x07\x06\x05\x04\x03\x02\x01 hello",
};
assert_eq!(0x0102030405060708, buf.get_u64_ne());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_u64_ne(&mut self) -> u64
fn try_get_u64_ne(&mut self) -> Result<u64>
sourcefn get_i64(&mut self) -> i64
fn get_i64(&mut self) -> i64
Gets a signed 64 bit integer from self
in big-endian byte order.
The current position is advanced by 8.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"[..];
assert_eq!(0x0102030405060708, buf.get_i64());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_i64(&mut self) -> i64
fn try_get_i64(&mut self) -> Result<i64>
sourcefn get_i64_le(&mut self) -> i64
fn get_i64_le(&mut self) -> i64
Gets a signed 64 bit integer from self
in little-endian byte order.
The current position is advanced by 8.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];
assert_eq!(0x0102030405060708, buf.get_i64_le());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_i64_le(&mut self) -> i64
fn try_get_i64_le(&mut self) -> Result<i64>
sourcefn get_i64_ne(&mut self) -> i64
fn get_i64_ne(&mut self) -> i64
Gets a signed 64 bit integer from self
in native-endian byte order.
The current position is advanced by 8.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x01\x02\x03\x04\x05\x06\x07\x08 hello",
false => b"\x08\x07\x06\x05\x04\x03\x02\x01 hello",
};
assert_eq!(0x0102030405060708, buf.get_i64_ne());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_i64_ne(&mut self) -> i64
fn try_get_i64_ne(&mut self) -> Result<i64>
sourcefn get_u128(&mut self) -> u128
fn get_u128(&mut self) -> u128
Gets an unsigned 128 bit integer from self
in big-endian byte order.
The current position is advanced by 16.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"[..];
assert_eq!(0x01020304050607080910111213141516, buf.get_u128());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_u128(&mut self) -> u128
fn try_get_u128(&mut self) -> Result<u128>
sourcefn get_u128_le(&mut self) -> u128
fn get_u128_le(&mut self) -> u128
Gets an unsigned 128 bit integer from self
in little-endian byte order.
The current position is advanced by 16.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];
assert_eq!(0x01020304050607080910111213141516, buf.get_u128_le());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_u128_le(&mut self) -> u128
fn try_get_u128_le(&mut self) -> Result<u128>
sourcefn get_u128_ne(&mut self) -> u128
fn get_u128_ne(&mut self) -> u128
Gets an unsigned 128 bit integer from self
in native-endian byte order.
The current position is advanced by 16.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello",
false => b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello",
};
assert_eq!(0x01020304050607080910111213141516, buf.get_u128_ne());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_u128_ne(&mut self) -> u128
fn try_get_u128_ne(&mut self) -> Result<u128>
sourcefn get_i128(&mut self) -> i128
fn get_i128(&mut self) -> i128
Gets a signed 128 bit integer from self
in big-endian byte order.
The current position is advanced by 16.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"[..];
assert_eq!(0x01020304050607080910111213141516, buf.get_i128());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_i128(&mut self) -> i128
fn try_get_i128(&mut self) -> Result<i128>
sourcefn get_i128_le(&mut self) -> i128
fn get_i128_le(&mut self) -> i128
Gets a signed 128 bit integer from self
in little-endian byte order.
The current position is advanced by 16.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];
assert_eq!(0x01020304050607080910111213141516, buf.get_i128_le());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_i128_le(&mut self) -> i128
fn try_get_i128_le(&mut self) -> Result<i128>
sourcefn get_i128_ne(&mut self) -> i128
fn get_i128_ne(&mut self) -> i128
Gets a signed 128 bit integer from self
in native-endian byte order.
The current position is advanced by 16.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello",
false => b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello",
};
assert_eq!(0x01020304050607080910111213141516, buf.get_i128_ne());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_i128_ne(&mut self) -> i128
fn try_get_i128_ne(&mut self) -> Result<i128>
sourcefn get_uint(&mut self, nbytes: usize) -> u64
fn get_uint(&mut self, nbytes: usize) -> u64
Gets an unsigned n-byte integer from self
in big-endian byte order.
The current position is advanced by nbytes
.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x01\x02\x03 hello"[..];
assert_eq!(0x010203, buf.get_uint(3));
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_uint(&mut self, nbytes: usize) -> u64
fn try_get_uint(&mut self, nbytes: usize) -> Result<u64>
sourcefn get_uint_le(&mut self, nbytes: usize) -> u64
fn get_uint_le(&mut self, nbytes: usize) -> u64
Gets an unsigned n-byte integer from self
in little-endian byte order.
The current position is advanced by nbytes
.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x03\x02\x01 hello"[..];
assert_eq!(0x010203, buf.get_uint_le(3));
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_uint_le(&mut self, nbytes: usize) -> u64
fn try_get_uint_le(&mut self, nbytes: usize) -> Result<u64>
sourcefn get_uint_ne(&mut self, nbytes: usize) -> u64
fn get_uint_ne(&mut self, nbytes: usize) -> u64
Gets an unsigned n-byte integer from self
in native-endian byte order.
The current position is advanced by nbytes
.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x01\x02\x03 hello",
false => b"\x03\x02\x01 hello",
};
assert_eq!(0x010203, buf.get_uint_ne(3));
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_uint_ne(&mut self, nbytes: usize) -> u64
fn try_get_uint_ne(&mut self, nbytes: usize) -> Result<u64>
fn peek_int(&mut self, nbytes: usize) -> i64
fn try_get_int(&mut self, nbytes: usize) -> Result<i64>
sourcefn get_int_le(&mut self, nbytes: usize) -> i64
fn get_int_le(&mut self, nbytes: usize) -> i64
Gets a signed n-byte integer from self
in little-endian byte order.
The current position is advanced by nbytes
.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x03\x02\x01 hello"[..];
assert_eq!(0x010203, buf.get_int_le(3));
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_int_le(&mut self, nbytes: usize) -> i64
fn try_get_int_le(&mut self, nbytes: usize) -> Result<i64>
sourcefn get_int_ne(&mut self, nbytes: usize) -> i64
fn get_int_ne(&mut self, nbytes: usize) -> i64
Gets a signed n-byte integer from self
in native-endian byte order.
The current position is advanced by nbytes
.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x01\x02\x03 hello",
false => b"\x03\x02\x01 hello",
};
assert_eq!(0x010203, buf.get_int_ne(3));
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_int_ne(&mut self, nbytes: usize) -> i64
fn try_get_int_ne(&mut self, nbytes: usize) -> Result<i64>
sourcefn get_f32(&mut self) -> f32
fn get_f32(&mut self) -> f32
Gets an IEEE754 single-precision (4 bytes) floating point number from
self
in big-endian byte order.
The current position is advanced by 4.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x3F\x99\x99\x9A hello"[..];
assert_eq!(1.2f32, buf.get_f32());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_f32(&mut self) -> f32
fn try_get_f32(&mut self) -> Result<f32>
sourcefn get_f32_le(&mut self) -> f32
fn get_f32_le(&mut self) -> f32
Gets an IEEE754 single-precision (4 bytes) floating point number from
self
in little-endian byte order.
The current position is advanced by 4.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x9A\x99\x99\x3F hello"[..];
assert_eq!(1.2f32, buf.get_f32_le());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_f32_le(&mut self) -> f32
fn try_get_f32_le(&mut self) -> Result<f32>
sourcefn get_f32_ne(&mut self) -> f32
fn get_f32_ne(&mut self) -> f32
Gets an IEEE754 single-precision (4 bytes) floating point number from
self
in native-endian byte order.
The current position is advanced by 4.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x3F\x99\x99\x9A hello",
false => b"\x9A\x99\x99\x3F hello",
};
assert_eq!(1.2f32, buf.get_f32_ne());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_f32_ne(&mut self) -> f32
fn try_get_f32_ne(&mut self) -> Result<f32>
sourcefn get_f64(&mut self) -> f64
fn get_f64(&mut self) -> f64
Gets an IEEE754 double-precision (8 bytes) floating point number from
self
in big-endian byte order.
The current position is advanced by 8.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x3F\xF3\x33\x33\x33\x33\x33\x33 hello"[..];
assert_eq!(1.2f64, buf.get_f64());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_f64(&mut self) -> f64
fn try_get_f64(&mut self) -> Result<f64>
sourcefn get_f64_le(&mut self) -> f64
fn get_f64_le(&mut self) -> f64
Gets an IEEE754 double-precision (8 bytes) floating point number from
self
in little-endian byte order.
The current position is advanced by 8.
§Examples
use algorithm::buf::Bt;
let mut buf = &b"\x33\x33\x33\x33\x33\x33\xF3\x3F hello"[..];
assert_eq!(1.2f64, buf.get_f64_le());
§Panics
This function panics if there is not enough remaining data in self
.
fn peek_f64_le(&mut self) -> f64
fn try_get_f64_le(&mut self) -> Result<f64>
sourcefn get_f64_ne(&mut self) -> f64
fn get_f64_ne(&mut self) -> f64
Gets an IEEE754 double-precision (8 bytes) floating point number from
self
in native-endian byte order.
The current position is advanced by 8.
§Examples
use algorithm::buf::Bt;
let mut buf: &[u8] = match cfg!(target_endian = "big") {
true => b"\x3F\xF3\x33\x33\x33\x33\x33\x33 hello",
false => b"\x33\x33\x33\x33\x33\x33\xF3\x3F hello",
};
assert_eq!(1.2f64, buf.get_f64_ne());
§Panics
This function panics if there is not enough remaining data in self
.