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§
Source§impl<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§
Source§impl<Base, Field> Debug for Offset<Base, Field>where
Base: DescribeOffset,
impl<Base, Field> Debug for Offset<Base, Field>where
Base: DescribeOffset,
Source§impl<Base, Field> Ord for Offset<Base, Field>
impl<Base, Field> Ord for Offset<Base, Field>
Source§impl<Base, Field> PartialOrd<&Offset<Base, Field>> for Offset<Base, Field>
impl<Base, Field> PartialOrd<&Offset<Base, Field>> for Offset<Base, Field>
Source§impl<Base, Field> PartialOrd<&u32> for Offset<Base, Field>
impl<Base, Field> PartialOrd<&u32> for Offset<Base, Field>
Source§impl<Base, Field> PartialOrd<u32> for Offset<Base, Field>
impl<Base, Field> PartialOrd<u32> for Offset<Base, Field>
Source§impl<Base, Field> PartialOrd for Offset<Base, Field>
impl<Base, Field> PartialOrd for Offset<Base, Field>
impl<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> Freeze for Offset<Base, Field>
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§
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