#[repr(transparent)]pub struct Offset<Base, Field> { /* private fields */ }
Expand description
An offset, representing a value of type Field
into a value of type Base
.
The value of the offset is internally stored as an u32
, so you are on
your own if you try to use that crate with a struct larger than 4 GiB.
Offsets can be added together as long as their types correspond, i.e. it is
possible to add an Offset<B, C>
to an Offset<A, B>
to get an
Offset<A, C>
.
Implementations
sourceimpl<Base, Field> Offset<Base, Field>
impl<Base, Field> Offset<Base, Field>
sourcepub const unsafe fn new_unchecked(value: u32) -> Self
pub const unsafe fn new_unchecked(value: u32) -> Self
Creates a new arbitrary offset.
Safety
There must be a value of type Field
at value
bytes away from
the start of a value of type Base
.
sourcepub const fn uninit(self) -> Offset<MaybeUninit<Base>, MaybeUninit<Field>>
pub const fn uninit(self) -> Offset<MaybeUninit<Base>, MaybeUninit<Field>>
Returns an offset suitable to be used with values of type MaybeUninit<Base>
.
sourcepub fn index_in(self, base: &Base) -> &Field
pub fn index_in(self, base: &Base) -> &Field
Returns a reference to the value of type Field
in base
at this offset.
sourcepub fn index_mut_in(self, base: &mut Base) -> &mut Field
pub fn index_mut_in(self, base: &mut Base) -> &mut Field
Returns a mutable reference to the value of type Field
in base
at this offset.
Trait Implementations
sourceimpl<Base, Field> Debug for Offset<Base, Field>where
Base: DescribeOffset,
impl<Base, Field> Debug for Offset<Base, Field>where
Base: DescribeOffset,
sourceimpl<Base, Field> Ord for Offset<Base, Field>
impl<Base, Field> Ord for Offset<Base, Field>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<Base, Field> PartialEq<&Offset<Base, Field>> for Offset<Base, Field>
impl<Base, Field> PartialEq<&Offset<Base, Field>> for Offset<Base, Field>
sourceimpl<Base, Field> PartialEq<&u32> for Offset<Base, Field>
impl<Base, Field> PartialEq<&u32> for Offset<Base, Field>
sourceimpl<Base, Field> PartialEq<Offset<Base, Field>> for Offset<Base, Field>
impl<Base, Field> PartialEq<Offset<Base, Field>> for Offset<Base, Field>
sourceimpl<Base, Field> PartialEq<u32> for Offset<Base, Field>
impl<Base, Field> PartialEq<u32> for Offset<Base, Field>
sourceimpl<Base, Field> PartialOrd<&Offset<Base, Field>> for Offset<Base, Field>
impl<Base, Field> PartialOrd<&Offset<Base, Field>> for Offset<Base, Field>
sourcefn partial_cmp(&self, other: &&Self) -> Option<Ordering>
fn partial_cmp(&self, other: &&Self) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl<Base, Field> PartialOrd<&u32> for Offset<Base, Field>
impl<Base, Field> PartialOrd<&u32> for Offset<Base, Field>
sourcefn partial_cmp(&self, other: &&u32) -> Option<Ordering>
fn partial_cmp(&self, other: &&u32) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl<Base, Field> PartialOrd<Offset<Base, Field>> for Offset<Base, Field>
impl<Base, Field> PartialOrd<Offset<Base, Field>> for Offset<Base, Field>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl<Base, Field> PartialOrd<u32> for Offset<Base, Field>
impl<Base, Field> PartialOrd<u32> for Offset<Base, Field>
sourcefn partial_cmp(&self, other: &u32) -> Option<Ordering>
fn partial_cmp(&self, other: &u32) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<Base, Field> Copy for Offset<Base, Field>
impl<Base, Field> Eq for Offset<Base, Field>
impl<Base, Field> Send for Offset<Base, Field>
impl<Base, Field> Sync for Offset<Base, Field>
Auto Trait Implementations
impl<Base, Field> RefUnwindSafe for Offset<Base, Field>where
Base: RefUnwindSafe,
Field: RefUnwindSafe,
impl<Base, Field> Unpin for Offset<Base, Field>
impl<Base, Field> UnwindSafe for Offset<Base, Field>where
Base: RefUnwindSafe,
Field: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more