Trait flatbuffers::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

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl EndianScalar for bool

§

type Scalar = u8

source§

fn to_little_endian(self) -> Self::Scalar

source§

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

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.

§

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.

§

type Scalar = u64

source§

impl EndianScalar for i8

§

type Scalar = i8

source§

fn to_little_endian(self) -> Self::Scalar

source§

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

source§

impl EndianScalar for i16

§

type Scalar = i16

source§

fn to_little_endian(self) -> Self::Scalar

source§

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

source§

impl EndianScalar for i32

§

type Scalar = i32

source§

fn to_little_endian(self) -> Self::Scalar

source§

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

source§

impl EndianScalar for i64

§

type Scalar = i64

source§

fn to_little_endian(self) -> Self::Scalar

source§

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

source§

impl EndianScalar for u8

§

type Scalar = u8

source§

fn to_little_endian(self) -> Self::Scalar

source§

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

source§

impl EndianScalar for u16

§

type Scalar = u16

source§

fn to_little_endian(self) -> Self::Scalar

source§

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

source§

impl EndianScalar for u32

§

type Scalar = u32

source§

fn to_little_endian(self) -> Self::Scalar

source§

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

source§

impl EndianScalar for u64

§

type Scalar = u64

source§

fn to_little_endian(self) -> Self::Scalar

source§

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

Implementors§