zerocopy::byteorder

Enum LittleEndian

Source
pub enum LittleEndian {}
Expand description

Defines little-endian serialization.

Note that this type has no value constructor. It is used purely at the type level.

§Examples

Write and read u32 numbers in little endian order:

use byteorder::{ByteOrder, LittleEndian};

let mut buf = [0; 4];
LittleEndian::write_u32(&mut buf, 1_000_000);
assert_eq!(1_000_000, LittleEndian::read_u32(&buf));

Trait Implementations§

Source§

impl ByteOrder for LittleEndian

Source§

fn read_u16(buf: &[u8]) -> u16

Reads an unsigned 16 bit integer from buf. Read more
Source§

fn read_u32(buf: &[u8]) -> u32

Reads an unsigned 32 bit integer from buf. Read more
Source§

fn read_u64(buf: &[u8]) -> u64

Reads an unsigned 64 bit integer from buf. Read more
Source§

fn read_u128(buf: &[u8]) -> u128

Reads an unsigned 128 bit integer from buf. Read more
Source§

fn read_uint(buf: &[u8], nbytes: usize) -> u64

Reads an unsigned n-bytes integer from buf. Read more
Source§

fn read_uint128(buf: &[u8], nbytes: usize) -> u128

Reads an unsigned n-bytes integer from buf. Read more
Source§

fn write_u16(buf: &mut [u8], n: u16)

Writes an unsigned 16 bit integer n to buf. Read more
Source§

fn write_u32(buf: &mut [u8], n: u32)

Writes an unsigned 32 bit integer n to buf. Read more
Source§

fn write_u64(buf: &mut [u8], n: u64)

Writes an unsigned 64 bit integer n to buf. Read more
Source§

fn write_u128(buf: &mut [u8], n: u128)

Writes an unsigned 128 bit integer n to buf. Read more
Source§

fn write_uint(buf: &mut [u8], n: u64, nbytes: usize)

Writes an unsigned integer n to buf using only nbytes. Read more
Source§

fn write_uint128(buf: &mut [u8], n: u128, nbytes: usize)

Writes an unsigned integer n to buf using only nbytes. Read more
Source§

fn read_u16_into(src: &[u8], dst: &mut [u16])

Reads unsigned 16 bit integers from src into dst. Read more
Source§

fn read_u32_into(src: &[u8], dst: &mut [u32])

Reads unsigned 32 bit integers from src into dst. Read more
Source§

fn read_u64_into(src: &[u8], dst: &mut [u64])

Reads unsigned 64 bit integers from src into dst. Read more
Source§

fn read_u128_into(src: &[u8], dst: &mut [u128])

Reads unsigned 128 bit integers from src into dst. Read more
Source§

fn write_u16_into(src: &[u16], dst: &mut [u8])

Writes unsigned 16 bit integers from src into dst. Read more
Source§

fn write_u32_into(src: &[u32], dst: &mut [u8])

Writes unsigned 32 bit integers from src into dst. Read more
Source§

fn write_u64_into(src: &[u64], dst: &mut [u8])

Writes unsigned 64 bit integers from src into dst. Read more
Source§

fn write_u128_into(src: &[u128], dst: &mut [u8])

Writes unsigned 128 bit integers from src into dst. Read more
Source§

fn from_slice_u16(numbers: &mut [u16])

Converts the given slice of unsigned 16 bit integers to a particular endianness. Read more
Source§

fn from_slice_u32(numbers: &mut [u32])

Converts the given slice of unsigned 32 bit integers to a particular endianness. Read more
Source§

fn from_slice_u64(numbers: &mut [u64])

Converts the given slice of unsigned 64 bit integers to a particular endianness. Read more
Source§

fn from_slice_u128(numbers: &mut [u128])

Converts the given slice of unsigned 128 bit integers to a particular endianness. Read more
Source§

fn from_slice_f32(numbers: &mut [f32])

Converts the given slice of IEEE754 single-precision (4 bytes) floating point numbers to a particular endianness. Read more
Source§

fn from_slice_f64(numbers: &mut [f64])

Converts the given slice of IEEE754 double-precision (8 bytes) floating point numbers to a particular endianness. Read more
Source§

fn read_u24(buf: &[u8]) -> u32

Reads an unsigned 24 bit integer from buf, stored in u32. Read more
Source§

fn read_u48(buf: &[u8]) -> u64

Reads an unsigned 48 bit integer from buf, stored in u64. Read more
Source§

fn write_u24(buf: &mut [u8], n: u32)

Writes an unsigned 24 bit integer n to buf, stored in u32. Read more
Source§

fn write_u48(buf: &mut [u8], n: u64)

Writes an unsigned 48 bit integer n to buf, stored in u64. Read more
Source§

fn read_i16(buf: &[u8]) -> i16

Reads a signed 16 bit integer from buf. Read more
Source§

fn read_i24(buf: &[u8]) -> i32

Reads a signed 24 bit integer from buf, stored in i32. Read more
Source§

fn read_i32(buf: &[u8]) -> i32

Reads a signed 32 bit integer from buf. Read more
Source§

fn read_i48(buf: &[u8]) -> i64

Reads a signed 48 bit integer from buf, stored in i64. Read more
Source§

fn read_i64(buf: &[u8]) -> i64

Reads a signed 64 bit integer from buf. Read more
Source§

fn read_i128(buf: &[u8]) -> i128

Reads a signed 128 bit integer from buf. Read more
Source§

fn read_int(buf: &[u8], nbytes: usize) -> i64

Reads a signed n-bytes integer from buf. Read more
Source§

fn read_int128(buf: &[u8], nbytes: usize) -> i128

Reads a signed n-bytes integer from buf. Read more
Source§

fn read_f32(buf: &[u8]) -> f32

Reads a IEEE754 single-precision (4 bytes) floating point number. Read more
Source§

fn read_f64(buf: &[u8]) -> f64

Reads a IEEE754 double-precision (8 bytes) floating point number. Read more
Source§

fn write_i16(buf: &mut [u8], n: i16)

Writes a signed 16 bit integer n to buf. Read more
Source§

fn write_i24(buf: &mut [u8], n: i32)

Writes a signed 24 bit integer n to buf, stored in i32. Read more
Source§

fn write_i32(buf: &mut [u8], n: i32)

Writes a signed 32 bit integer n to buf. Read more
Source§

fn write_i48(buf: &mut [u8], n: i64)

Writes a signed 48 bit integer n to buf, stored in i64. Read more
Source§

fn write_i64(buf: &mut [u8], n: i64)

Writes a signed 64 bit integer n to buf. Read more
Source§

fn write_i128(buf: &mut [u8], n: i128)

Writes a signed 128 bit integer n to buf. Read more
Source§

fn write_int(buf: &mut [u8], n: i64, nbytes: usize)

Writes a signed integer n to buf using only nbytes. Read more
Source§

fn write_int128(buf: &mut [u8], n: i128, nbytes: usize)

Writes a signed integer n to buf using only nbytes. Read more
Source§

fn write_f32(buf: &mut [u8], n: f32)

Writes a IEEE754 single-precision (4 bytes) floating point number. Read more
Source§

fn write_f64(buf: &mut [u8], n: f64)

Writes a IEEE754 double-precision (8 bytes) floating point number. Read more
Source§

fn read_i16_into(src: &[u8], dst: &mut [i16])

Reads signed 16 bit integers from src to dst. Read more
Source§

fn read_i32_into(src: &[u8], dst: &mut [i32])

Reads signed 32 bit integers from src into dst. Read more
Source§

fn read_i64_into(src: &[u8], dst: &mut [i64])

Reads signed 64 bit integers from src into dst. Read more
Source§

fn read_i128_into(src: &[u8], dst: &mut [i128])

Reads signed 128 bit integers from src into dst. Read more
Source§

fn read_f32_into(src: &[u8], dst: &mut [f32])

Reads IEEE754 single-precision (4 bytes) floating point numbers from src into dst. Read more
Source§

fn read_f32_into_unchecked(src: &[u8], dst: &mut [f32])

👎Deprecated since 1.3.0: please use read_f32_into instead
DEPRECATED. Read more
Source§

fn read_f64_into(src: &[u8], dst: &mut [f64])

Reads IEEE754 single-precision (4 bytes) floating point numbers from src into dst. Read more
Source§

fn read_f64_into_unchecked(src: &[u8], dst: &mut [f64])

👎Deprecated since 1.3.0: please use read_f64_into instead
DEPRECATED. Read more
Source§

fn write_i8_into(src: &[i8], dst: &mut [u8])

Writes signed 8 bit integers from src into dst. Read more
Source§

fn write_i16_into(src: &[i16], dst: &mut [u8])

Writes signed 16 bit integers from src into dst. Read more
Source§

fn write_i32_into(src: &[i32], dst: &mut [u8])

Writes signed 32 bit integers from src into dst. Read more
Source§

fn write_i64_into(src: &[i64], dst: &mut [u8])

Writes signed 64 bit integers from src into dst. Read more
Source§

fn write_i128_into(src: &[i128], dst: &mut [u8])

Writes signed 128 bit integers from src into dst. Read more
Source§

fn write_f32_into(src: &[f32], dst: &mut [u8])

Writes IEEE754 single-precision (4 bytes) floating point numbers from src into dst. Read more
Source§

fn write_f64_into(src: &[f64], dst: &mut [u8])

Writes IEEE754 double-precision (8 bytes) floating point numbers from src into dst. Read more
Source§

fn from_slice_i16(src: &mut [i16])

Converts the given slice of signed 16 bit integers to a particular endianness. Read more
Source§

fn from_slice_i32(src: &mut [i32])

Converts the given slice of signed 32 bit integers to a particular endianness. Read more
Source§

fn from_slice_i64(src: &mut [i64])

Converts the given slice of signed 64 bit integers to a particular endianness. Read more
Source§

fn from_slice_i128(src: &mut [i128])

Converts the given slice of signed 128 bit integers to a particular endianness. Read more
Source§

impl Clone for LittleEndian

Source§

fn clone(&self) -> LittleEndian

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LittleEndian

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for LittleEndian

Source§

fn default() -> LittleEndian

Returns the “default value” for a type. Read more
Source§

impl Hash for LittleEndian

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for LittleEndian

Source§

fn cmp(&self, other: &LittleEndian) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for LittleEndian

Source§

fn eq(&self, other: &LittleEndian) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for LittleEndian

Source§

fn partial_cmp(&self, other: &LittleEndian) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for LittleEndian

Source§

impl Eq for LittleEndian

Source§

impl StructuralPartialEq for LittleEndian

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.