flatbuffers

Trait EndianScalar

Source
pub trait EndianScalar:
    Sized
    + PartialEq
    + Copy
    + Clone {
    type Scalar: TriviallyTransmutable;

    // Required methods
    fn to_little_endian(self) -> Self::Scalar;
    fn from_little_endian(v: Self::Scalar) -> Self;
}
Expand description

Trait for values that must be stored in little-endian byte order, but might be represented in memory as big-endian. Every type that implements EndianScalar is a valid FlatBuffers scalar value.

The Rust stdlib does not provide a trait to represent scalars, so this trait serves that purpose, too.

Note that we do not use the num-traits crate for this, because it provides “too much”. For example, num-traits provides i128 support, but that is an invalid FlatBuffers type.

Required Associated Types§

Source

type Scalar: TriviallyTransmutable

Required Methods§

Source

fn to_little_endian(self) -> Self::Scalar

Source

fn from_little_endian(v: Self::Scalar) -> Self

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.

Implementations on Foreign Types§

Source§

impl EndianScalar for bool

Source§

impl EndianScalar for f32

Source§

fn to_little_endian(self) -> u32

Convert f32 from host endian-ness to little-endian.

Source§

fn from_little_endian(v: u32) -> Self

Convert f32 from little-endian to host endian-ness.

Source§

type Scalar = u32

Source§

impl EndianScalar for f64

Source§

fn to_little_endian(self) -> u64

Convert f64 from host endian-ness to little-endian.

Source§

fn from_little_endian(v: u64) -> Self

Convert f64 from little-endian to host endian-ness.

Source§

type Scalar = u64

Source§

impl EndianScalar for i8

Source§

impl EndianScalar for i16

Source§

impl EndianScalar for i32

Source§

impl EndianScalar for i64

Source§

impl EndianScalar for u8

Source§

impl EndianScalar for u16

Source§

impl EndianScalar for u32

Source§

impl EndianScalar for u64

Implementors§