Struct repr_offset::get_field_offset::FieldOffsetWithVis[][src]

#[repr(transparent)]pub struct FieldOffsetWithVis<S, V, FN, F, A> { /* fields omitted */ }

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

impl<S, V, FN, F, A> FieldOffsetWithVis<S, V, FN, F, A>[src]

pub const unsafe fn new(offset: usize) -> Self[src]

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.

pub const unsafe fn from_fieldoffset(offset: FieldOffset<S, F, A>) -> Self[src]

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.

impl<FN, S, F, A> FieldOffsetWithVis<S, IsPublic, FN, F, A>[src]

pub const fn to_field_offset(self) -> FieldOffset<S, F, A>[src]

Unwraps this into a FieldOffset for a public field.

impl<S, V, FN, F, A> FieldOffsetWithVis<S, V, FN, F, A>[src]

pub const unsafe fn private_field_offset(self) -> FieldOffset<S, F, A>[src]

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.

pub const unsafe fn cast_struct<SO>(self) -> FieldOffsetWithVis<SO, V, FN, F, A>[src]

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

impl<S, V, FN, F, A> Clone for FieldOffsetWithVis<S, V, FN, F, A>[src]

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

Auto Trait Implementations

impl<S, V, FN, F, A> Send for FieldOffsetWithVis<S, V, FN, F, A>[src]

impl<S, V, FN, F, A> Sync for FieldOffsetWithVis<S, V, FN, F, A>[src]

impl<S, V, FN, F, A> Unpin for FieldOffsetWithVis<S, V, FN, F, A>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<S> ROExtAcc for S[src]

impl<S> ROExtOps<Aligned> for S[src]

impl<S> ROExtOps<Unaligned> for S[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.