#[repr(transparent)]
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>

source

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 is pub.

  • IsPrivate: When the field has the default (private) visibility, or has a visibility smaller or equal to pub(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

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 is pub.

  • IsPrivate: When the field has the default (private) visibility, or has a visibility smaller or equal to pub(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>

source

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>

source

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.

source

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>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S, V, FN, F, A> Copy for FieldOffsetWithVis<S, V, FN, F, A>

Auto Trait Implementations§

§

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> 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<S> ROExtAcc for S

source§

fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F

Gets a reference to a field, determined by offset. Read more
source§

fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F

Gets a muatble reference to a field, determined by offset. Read more
source§

fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F

Gets a const pointer to a field, the field is determined by offset. Read more
source§

fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F

Gets a mutable pointer to a field, determined by offset. Read more
source§

impl<S> ROExtOps<Aligned> for S

source§

fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F

Replaces a field (determined by offset) with value, returning the previous value of the field. Read more
source§

fn f_swap<F>(&mut self, offset: FieldOffset<S, F, Aligned>, right: &mut S)

Swaps a field (determined by offset) with the same field in right. Read more
source§

fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere F: Copy,

Gets a copy of a field (determined by offset). The field is determined by offset. Read more
source§

impl<S> ROExtOps<Unaligned> for S

source§

fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F

Replaces a field (determined by offset) with value, returning the previous value of the field. Read more
source§

fn f_swap<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, right: &mut S)

Swaps a field (determined by offset) with the same field in right. Read more
source§

fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere F: Copy,

Gets a copy of a field (determined by offset). The field is determined by offset. Read more
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.