pub struct Field<T, const LO: u32, const HI: u32>(/* private fields */);Expand description
One value packed into bits LO..=HI of a panel, inclusive, MSB-first from byte 0.
Never instantiated — it names a position plus a conversion, used as
MyField::get(&raw) / MyField::set(&mut raw, v).
ⓘ
use nord_format::bits::Field;
let _ = Field::<u8, 0, 15>::read(&[0; 2]);A one-bit type cannot decode a wider field:
ⓘ
use nord_format::bits::Field;
let _ = Field::<bool, 0, 1>::read(&[0]);A Packed implementation cannot advertise more value bits than it can decode:
ⓘ
use nord_format::bits::{Field, Packed};
use std::convert::Infallible;
struct Invalid;
impl Packed for Invalid {
const MAX_BITS: u32 = 2;
const DECODE_BITS: u32 = 1;
type Error = Infallible;
fn from_bits(_: u64) -> Result<Self, Infallible> { Ok(Self) }
fn to_bits(&self) -> u64 { 0 }
}
let _ = Field::<Invalid, 0, 1>::get::<1>(&[0]);Implementations§
Auto Trait Implementations§
impl<T, const LO: u32, const HI: u32> Freeze for Field<T, LO, HI>
impl<T, const LO: u32, const HI: u32> RefUnwindSafe for Field<T, LO, HI>
impl<T, const LO: u32, const HI: u32> Send for Field<T, LO, HI>
impl<T, const LO: u32, const HI: u32> Sync for Field<T, LO, HI>
impl<T, const LO: u32, const HI: u32> Unpin for Field<T, LO, HI>
impl<T, const LO: u32, const HI: u32> UnsafeUnpin for Field<T, LO, HI>
impl<T, const LO: u32, const HI: u32> UnwindSafe for Field<T, LO, HI>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more