Trait mycelium_bitfield::FromBits
source · [−]pub trait FromBits<B>: Sized {
type Error: Display;
const BITS: u32;
fn try_from_bits(bits: B) -> Result<Self, Self::Error>;
fn into_bits(self) -> B;
}
Expand description
Trait implemented by values which can be converted to and from raw bits.
Required Associated Types
The error type returned by Self::try_from_bits
when an invalid bit
pattern is encountered.
If all bit patterns possible in Self::BITS
bits are valid bit
patterns for a Self
-typed value, this should generally be
core::convert::Infallible
.
Required Associated Constants
Required Methods
fn try_from_bits(bits: B) -> Result<Self, Self::Error>
fn try_from_bits(bits: B) -> Result<Self, Self::Error>
Attempt to convert bits
into a value of this type.
Returns
Ok(Self)
ifbits
contained a valid bit pattern for a value of this type.Err(Self::Error)
ifbits
is an invalid bit pattern for a value of this type.