Struct bit_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> RefUnwindSafe for GetSet<'a, P, T, START, STOP>where
P: RefUnwindSafe,
T: RefUnwindSafe,

§

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 Twhere
T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.