Struct repr_offset::get_field_offset::FieldOffsetWithVis
source · pub struct FieldOffsetWithVis<S, V, FN, F, A> { /* private fields */ }
Expand description
A wrapper around a FieldOffset
, with a visibility type parameter
(whether the field is pub or not).
§Type parameters
S
: The type that contains the field
V
: The visibility of the field, either IsPrivate
or IsPublic
.
FN
: The name of the field, written using the repr_offset::tstr::TS
macro,
written as TS!(field_name)
.
F
: The type of the field.
A
: The alignment of the field inside of S
, either Aligned
or Unaligned
.
Implementations§
source§impl<S, V, FN, F, A> FieldOffsetWithVis<S, V, FN, F, A>
impl<S, V, FN, F, A> FieldOffsetWithVis<S, V, FN, F, A>
sourcepub const unsafe fn new(offset: usize) -> Self
pub const unsafe fn new(offset: usize) -> Self
Constructs this FieldOffsetWithVis
from the offset
(in bytes) of a field.
§Safety
This method has a superset of the safety requirements of FieldOffset::new
.
The V
type parameter must be:
-
IsPublic
: When the field ispub
. -
IsPrivate
: When the field has the default (private) visibility, or has a visibility smaller or equal topub(crate)
.
The FN
type parameter must be the name of the field using the
repr_offset::tstr::TS
macro,
eg: TS!(foo)
for the foo
field.
sourcepub const unsafe fn from_fieldoffset(offset: FieldOffset<S, F, A>) -> Self
pub const unsafe fn from_fieldoffset(offset: FieldOffset<S, F, A>) -> Self
Constructs this FieldOffsetWithVis
from offset
.
§Safety
The V
type parameter must be:
-
IsPublic
: When the field ispub
. -
IsPrivate
: When the field has the default (private) visibility, or has a visibility smaller or equal topub(crate)
.
The FN
type parameter must be the name of the field using the
repr_offset::tstr::TS
macro,
eg: TS!(foo)
for the foo
field.
source§impl<FN, S, F, A> FieldOffsetWithVis<S, IsPublic, FN, F, A>
impl<FN, S, F, A> FieldOffsetWithVis<S, IsPublic, FN, F, A>
sourcepub const fn to_field_offset(self) -> FieldOffset<S, F, A>
pub const fn to_field_offset(self) -> FieldOffset<S, F, A>
Unwraps this into a FieldOffset
for a public field.
source§impl<S, V, FN, F, A> FieldOffsetWithVis<S, V, FN, F, A>
impl<S, V, FN, F, A> FieldOffsetWithVis<S, V, FN, F, A>
sourcepub const unsafe fn private_field_offset(self) -> FieldOffset<S, F, A>
pub const unsafe fn private_field_offset(self) -> FieldOffset<S, F, A>
Unwraps this into a FieldOffset
for a possibly private field.
§Safety
Because the field may be private, modifying its state could cause undefined behavior, and is only supposed to be done in a context where the field is accessible.
sourcepub const unsafe fn cast_struct<SO>(self) -> FieldOffsetWithVis<SO, V, FN, F, A>
pub const unsafe fn cast_struct<SO>(self) -> FieldOffsetWithVis<SO, V, FN, F, A>
Casts this FieldOffsetWithVis
to be for a different struct.
This is mostly useful for #[repr(transparent)]
types to delegate to
their single field.
§Safety
SO
must contain a field of type S
as its first field in memory,
at offset 0.
Trait Implementations§
source§impl<S, V, FN, F, A> Clone for FieldOffsetWithVis<S, V, FN, F, A>
impl<S, V, FN, F, A> Clone for FieldOffsetWithVis<S, V, FN, F, A>
impl<S, V, FN, F, A> Copy for FieldOffsetWithVis<S, V, FN, F, A>
Auto Trait Implementations§
impl<S, V, FN, F, A> Freeze for FieldOffsetWithVis<S, V, FN, F, A>
impl<S, V, FN, F, A> RefUnwindSafe for FieldOffsetWithVis<S, V, FN, F, A>
impl<S, V, FN, F, A> Send for FieldOffsetWithVis<S, V, FN, F, A>
impl<S, V, FN, F, A> Sync for FieldOffsetWithVis<S, V, FN, F, A>
impl<S, V, FN, F, A> Unpin for FieldOffsetWithVis<S, V, FN, F, A>
impl<S, V, FN, F, A> UnwindSafe for FieldOffsetWithVis<S, V, FN, F, A>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset
. Read moresource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset
. Read moresource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset
. Read moresource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset
. Read moresource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read moresource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read more