Trait Endian

Source
pub trait Endian: Copy + Sealed {
    type Opposite;

Show 32 methods // Required methods fn is_native(self) -> bool; fn into_opposite(self) -> Self::Opposite; fn read_i16<R>(self, reader: R) -> IoResult<i16> where R: Read; fn read_u16<R>(self, reader: R) -> IoResult<u16> where R: Read; fn read_i32<R>(self, reader: R) -> IoResult<i32> where R: Read; fn read_u32<R>(self, reader: R) -> IoResult<u32> where R: Read; fn read_i64<R>(self, reader: R) -> IoResult<i64> where R: Read; fn read_u64<R>(self, reader: R) -> IoResult<u64> where R: Read; fn read_i128<R>(self, reader: R) -> IoResult<i128> where R: Read; fn read_u128<R>(self, reader: R) -> IoResult<u128> where R: Read; fn read_f32<R>(self, reader: R) -> IoResult<f32> where R: Read; fn read_f64<R>(self, reader: R) -> IoResult<f64> where R: Read; fn write_i16<W>(self, writer: W, v: i16) -> IoResult<()> where W: Write; fn write_u16<W>(self, writer: W, v: u16) -> IoResult<()> where W: Write; fn write_i32<W>(self, writer: W, v: i32) -> IoResult<()> where W: Write; fn write_u32<W>(self, writer: W, v: u32) -> IoResult<()> where W: Write; fn write_i64<W>(self, writer: W, v: i64) -> IoResult<()> where W: Write; fn write_u64<W>(self, writer: W, v: u64) -> IoResult<()> where W: Write; fn write_i128<W>(self, writer: W, v: i128) -> IoResult<()> where W: Write; fn write_u128<W>(self, writer: W, v: u128) -> IoResult<()> where W: Write; fn write_f32<W>(self, writer: W, v: f32) -> IoResult<()> where W: Write; fn write_f64<W>(self, writer: W, v: f64) -> IoResult<()> where W: Write; // Provided methods fn read_i16_into<R>(self, reader: R, dst: &mut [i16]) -> IoResult<()> where R: Read { ... } fn read_u16_into<R>(self, reader: R, dst: &mut [u16]) -> IoResult<()> where R: Read { ... } fn read_i32_into<R>(self, reader: R, dst: &mut [i32]) -> IoResult<()> where R: Read { ... } fn read_u32_into<R>(self, reader: R, dst: &mut [u32]) -> IoResult<()> where R: Read { ... } fn read_i64_into<R>(self, reader: R, dst: &mut [i64]) -> IoResult<()> where R: Read { ... } fn read_u64_into<R>(self, reader: R, dst: &mut [u64]) -> IoResult<()> where R: Read { ... } fn read_i128_into<R>(self, reader: R, dst: &mut [i128]) -> IoResult<()> where R: Read { ... } fn read_u128_into<R>(self, reader: R, dst: &mut [u128]) -> IoResult<()> where R: Read { ... } fn read_f32_into<R>(self, reader: R, dst: &mut [f32]) -> IoResult<()> where R: Read { ... } fn read_f64_into<R>(self, reader: R, dst: &mut [f64]) -> IoResult<()> where R: Read { ... }
}
Expand description

General trait for types that can serialize and deserialize bytes in some byte order.

The trait roughly resembles byteorder::ByteOrder, with the exception that it is implemented for material types, which are also Copy, and all methods receive self. This makes it possible to embed byte order information to a reader or writer by composition, which is done by ByteOrdered.

Required Associated Types§

Source

type Opposite

A type which can represent a byte order that is opposite to this one.

Required Methods§

Source

fn is_native(self) -> bool

Checks whether this value represents the system’s native endianness.

Source

fn into_opposite(self) -> Self::Opposite

Converts the receiver into its opposite.

Source

fn read_i16<R>(self, reader: R) -> IoResult<i16>
where R: Read,

Reads a signed 16 bit integer from the given reader.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_u16<R>(self, reader: R) -> IoResult<u16>
where R: Read,

Reads an unsigned 16 bit integer from the given reader.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_i32<R>(self, reader: R) -> IoResult<i32>
where R: Read,

Reads a signed 32 bit integer from the given reader.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_u32<R>(self, reader: R) -> IoResult<u32>
where R: Read,

Reads an unsigned 32 bit integer from the given reader.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_i64<R>(self, reader: R) -> IoResult<i64>
where R: Read,

Reads a signed 64 bit integer from the given reader.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_u64<R>(self, reader: R) -> IoResult<u64>
where R: Read,

Reads an unsigned 64 bit integer from the given reader.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_i128<R>(self, reader: R) -> IoResult<i128>
where R: Read,

Reads a signed 128 bit integer from the given reader.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_u128<R>(self, reader: R) -> IoResult<u128>
where R: Read,

Reads an unsigned 128 bit integer from the given reader.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_f32<R>(self, reader: R) -> IoResult<f32>
where R: Read,

Reads a IEEE754 single-precision (4 bytes) floating point number from the given reader.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_f64<R>(self, reader: R) -> IoResult<f64>
where R: Read,

Reads a IEEE754 double-precision (8 bytes) floating point number from the given reader.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn write_i16<W>(self, writer: W, v: i16) -> IoResult<()>
where W: Write,

Writes a signed 16 bit integer to the given writer.

§Errors

This method returns the same errors as Write::write_all.

Source

fn write_u16<W>(self, writer: W, v: u16) -> IoResult<()>
where W: Write,

Writes an unsigned 16 bit integer to the given writer.

§Errors

This method returns the same errors as Write::write_all.

Source

fn write_i32<W>(self, writer: W, v: i32) -> IoResult<()>
where W: Write,

Writes a signed 32 bit integer to the given writer.

§Errors

This method returns the same errors as Write::write_all.

Source

fn write_u32<W>(self, writer: W, v: u32) -> IoResult<()>
where W: Write,

Writes an unsigned 32 bit integer to the given writer.

§Errors

This method returns the same errors as Write::write_all.

Source

fn write_i64<W>(self, writer: W, v: i64) -> IoResult<()>
where W: Write,

Writes a signed 64 bit integer to the given writer.

§Errors

This method returns the same errors as Write::write_all.

Source

fn write_u64<W>(self, writer: W, v: u64) -> IoResult<()>
where W: Write,

Writes an unsigned 64 bit integer to the given writer.

§Errors

This method returns the same errors as Write::write_all.

Source

fn write_i128<W>(self, writer: W, v: i128) -> IoResult<()>
where W: Write,

Writes a signed 128 bit integer to the given writer.

§Errors

This method returns the same errors as Write::write_all.

Source

fn write_u128<W>(self, writer: W, v: u128) -> IoResult<()>
where W: Write,

Writes an unsigned 128 bit integer to the given writer.

§Errors

This method returns the same errors as Write::write_all.

Source

fn write_f32<W>(self, writer: W, v: f32) -> IoResult<()>
where W: Write,

Writes a IEEE754 single-precision (4 bytes) floating point number to the given writer.

§Errors

This method returns the same errors as Write::write_all.

Source

fn write_f64<W>(self, writer: W, v: f64) -> IoResult<()>
where W: Write,

Writes a IEEE754 double-precision (8 bytes) floating point number to the given writer.

§Errors

This method returns the same errors as Write::write_all.

Provided Methods§

Source

fn read_i16_into<R>(self, reader: R, dst: &mut [i16]) -> IoResult<()>
where R: Read,

Reads a sequence of signed 16 bit integers from the given reader.

The given buffer is either filled completely or an error is returned. If an error is returned, the contents of dst are unspecified.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_u16_into<R>(self, reader: R, dst: &mut [u16]) -> IoResult<()>
where R: Read,

Reads a sequence of unsigned 16 bit integers from the given reader.

The given buffer is either filled completely or an error is returned. If an error is returned, the contents of dst are unspecified.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_i32_into<R>(self, reader: R, dst: &mut [i32]) -> IoResult<()>
where R: Read,

Reads a sequence of signed 32 bit integers from the given reader.

The given buffer is either filled completely or an error is returned. If an error is returned, the contents of dst are unspecified.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_u32_into<R>(self, reader: R, dst: &mut [u32]) -> IoResult<()>
where R: Read,

Reads a sequence of unsigned 32 bit integers from the given reader.

The given buffer is either filled completely or an error is returned. If an error is returned, the contents of dst are unspecified.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_i64_into<R>(self, reader: R, dst: &mut [i64]) -> IoResult<()>
where R: Read,

Reads a sequence of signed 64 bit integers from the given reader.

The given buffer is either filled completely or an error is returned. If an error is returned, the contents of dst are unspecified.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_u64_into<R>(self, reader: R, dst: &mut [u64]) -> IoResult<()>
where R: Read,

Reads a sequence of unsigned 64 bit integers from the given reader.

The given buffer is either filled completely or an error is returned. If an error is returned, the contents of dst are unspecified.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_i128_into<R>(self, reader: R, dst: &mut [i128]) -> IoResult<()>
where R: Read,

Reads a sequence of signed 128 bit integers from the given reader.

The given buffer is either filled completely or an error is returned. If an error is returned, the contents of dst are unspecified.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_u128_into<R>(self, reader: R, dst: &mut [u128]) -> IoResult<()>
where R: Read,

Reads a sequence of unsigned 128 bit integers from the given reader.

The given buffer is either filled completely or an error is returned. If an error is returned, the contents of dst are unspecified.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_f32_into<R>(self, reader: R, dst: &mut [f32]) -> IoResult<()>
where R: Read,

Reads a sequence of IEEE754 single-precision (4 bytes) floating point numbers from the given reader.

The given buffer is either filled completely or an error is returned. If an error is returned, the contents of dst are unspecified.

§Errors

This method returns the same errors as Read::read_exact.

Source

fn read_f64_into<R>(self, reader: R, dst: &mut [f64]) -> IoResult<()>
where R: Read,

Reads a sequence of IEEE754 double-precision (8 bytes) floating point numbers from the given reader.

The given buffer is either filled completely or an error is returned. If an error is returned, the contents of dst are unspecified.

§Errors

This method returns the same errors as Read::read_exact.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Endian for Endianness

Source§

impl<E> Endian for StaticEndianness<E>
where E: HasOpposite + StaticNative + ByteOrder,

Source§

type Opposite = StaticEndianness<<E as HasOpposite>::Opposite>