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§
Required Methods§
fn to_little_endian(self) -> Self::Scalar
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.