Struct GetSet

Source
pub struct GetSet<'a, P, T, const START: usize, const STOP: usize> { /* private fields */ }
Expand description

A struct which allows for getting/setting a given property

Implementations§

Source§

impl<'a, P, T, const START: usize, const STOP: usize> GetSet<'a, P, T, START, STOP>

Source

pub const fn start(&self) -> usize

The bit offset at which this GetSet instance starts

Source

pub const fn stop(&self) -> usize

The bit offset at which this GetSet instance ends

Source§

impl<'a, P: Num + Bounded + ShlAssign<usize> + ShrAssign<usize> + BitCount, T, const START: usize, const STOP: usize> GetSet<'a, P, T, START, STOP>

Source

pub fn new(parent: &'a mut P) -> Self

Create a new GetSet. This should be called from methods generated by the bit_struct macro

Source§

impl<'a, P: Num + Shl<usize, Output = P> + Shr<usize, Output = P> + ShlAssign<usize> + ShrAssign<usize> + Bounded + BitAnd<Output = P> + Copy + BitCount, T: ValidCheck<P>, const START: usize, const STOP: usize> GetSet<'a, P, T, START, STOP>

Source

pub fn get(&self) -> T

Get the property this GetSet points at

Source

pub fn is_valid(&self) -> bool

Returns true if the memory this GetSet points at is a valid representation of T

Source

pub fn get_raw(&self) -> P

Get the raw bits being pointed at, without type conversion nor any form of validation

Source§

impl<'a, P, T, const START: usize, const STOP: usize> GetSet<'a, P, T, START, STOP>
where T: FieldStorage + BitsFitIn<P>, P: Num + Shl<usize, Output = P> + Copy + BitOrAssign + BitXorAssign + BitAnd<Output = P> + ShlAssign<usize> + ShrAssign<usize> + PartialOrd + Bounded + Sized + BitCount,

Source

pub fn set(&mut self, value: T)

Set the property in the slice being pointed to by this GetSet

Source

pub unsafe fn set_raw(&mut self, value: P)

Set the field to a raw value.

§Safety

value must be a valid representation of the field. i.e., core::mem::transmute between P and T must be defined.

Auto Trait Implementations§

§

impl<'a, P, T, const START: usize, const STOP: usize> Freeze for GetSet<'a, P, T, START, STOP>

§

impl<'a, P, T, const START: usize, const STOP: usize> RefUnwindSafe for GetSet<'a, P, T, START, STOP>

§

impl<'a, P, T, const START: usize, const STOP: usize> Send for GetSet<'a, P, T, START, STOP>
where P: Send, T: Send,

§

impl<'a, P, T, const START: usize, const STOP: usize> Sync for GetSet<'a, P, T, START, STOP>
where P: Sync, T: Sync,

§

impl<'a, P, T, const START: usize, const STOP: usize> Unpin for GetSet<'a, P, T, START, STOP>

§

impl<'a, P, T, const START: usize, const STOP: usize> !UnwindSafe for GetSet<'a, P, T, START, STOP>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.