pub trait RealType:
Sized
+ Debug
+ Display {
const BYTE_WIDTH: usize;
const INFINITY: Self;
const NEG_INFINITY: Self;
const NAN: Self;
// Required methods
fn to_ieee754_bytes(&self) -> (impl AsRef<[u8]>, usize);
fn try_from_ieee754_bytes(bytes: &[u8]) -> Result<Self, TryFromRealError>;
fn try_from_float(value: impl FloatCore) -> Option<Self>;
fn try_to_float(&self) -> Option<impl FloatCore>;
fn is_infinity(&self) -> bool;
fn is_neg_infinity(&self) -> bool;
fn is_nan(&self) -> bool;
}Expand description
Represents a real type in Rust that can be decoded or encoded into any ASN.1 codec.
Required Associated Constants§
Sourceconst BYTE_WIDTH: usize
const BYTE_WIDTH: usize
The byte level width of the floating point type.
Sourceconst NEG_INFINITY: Self
const NEG_INFINITY: Self
The negative infinity (-∞) value
Required Methods§
Sourcefn to_ieee754_bytes(&self) -> (impl AsRef<[u8]>, usize)
fn to_ieee754_bytes(&self) -> (impl AsRef<[u8]>, usize)
Returns the IEEE 754 encoded bytes of the real type, byte count defined in usize
Sourcefn try_from_ieee754_bytes(bytes: &[u8]) -> Result<Self, TryFromRealError>
fn try_from_ieee754_bytes(bytes: &[u8]) -> Result<Self, TryFromRealError>
Attempts to decode the IEEE 754 encoded bytes into Self
Sourcefn try_from_float(value: impl FloatCore) -> Option<Self>
fn try_from_float(value: impl FloatCore) -> Option<Self>
Attempts to convert a generic floating point type into Self
Sourcefn try_to_float(&self) -> Option<impl FloatCore>
fn try_to_float(&self) -> Option<impl FloatCore>
Attempts to convert Self into a generic floating point type
Sourcefn is_infinity(&self) -> bool
fn is_infinity(&self) -> bool
Returns true if the value is positive infinity
Sourcefn is_neg_infinity(&self) -> bool
fn is_neg_infinity(&self) -> bool
Returns true if the value is negative infinity
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.