RawLateFieldDescriptor

Struct RawLateFieldDescriptor 

Source
pub struct RawLateFieldDescriptor { /* private fields */ }
Expand description

A raw (untyped) descriptor for a LateField.

You can obtain a reference to this descriptor using LateField::raw_descriptor.

Unlike LateFieldDescriptor, the type of the LateStruct to which this descriptor belongs is erased. There is no descriptor which also specifies the type of the LateField since it would be redundant.

Implementations§

Source§

impl RawLateFieldDescriptor

Source

pub fn parent_struct(&self) -> &'static RawLateStructDescriptor

Fetches the descriptor of the struct to which this field belongs.

Source

pub fn index(&self, token: LateLayoutInitToken) -> usize

Fetches the index of the field within the RawLateStructDescriptor::fields list of the struct to which this field belongs. The ordering of these indices is not stable across compilations.

Source

pub fn offset(&self, token: LateLayoutInitToken) -> usize

Fetches the offset of this field’s value within the overall struct.

Source

pub fn layout(&self) -> Layout

Fetches the layout of the field’s value.

Source

pub unsafe fn init(&self, value: *mut u8)

Initializes value to an instance of the field’s value obtained by calling its Default implementation.

§Safety

value must point to an uninitialized location in memory large enough to accommodate the field’s value.

Source

pub unsafe fn drop(&self, value: *mut u8)

Drops the instance of the field’s value pointed to by value.

§Safety

value must point to an initialized instance of the field’s value.

Source

pub unsafe fn erase_value<S: LateStruct>( &self, value: *mut u8, ) -> *mut S::EraseTo

Adorns an untyped pointer in memory with the metadata required to become a pointer to the specified LateStruct’s S::EraseTo type.

value need not point to a valid location in memory.

This operation can be performed safely by converting this descriptor into a LateFieldDescriptor using the RawLateFieldDescriptor::typed method and calling its LateFieldDescriptor::erase_value method.

§Safety

S must match the type of the LateStruct marker this descriptor is describing.

Source

pub fn key_type_name(&self) -> &'static str

Fetches the type_name of the LateField instance—that is, the name of the marker type.

Source

pub fn key_type_id(&self) -> TypeId

Fetches the TypeId of the LateField instance—that is, the ID of the marker type.

Source

pub fn typed<S: LateStruct>(&self) -> &LateFieldDescriptor<S>

Downcasts the descriptor to a typed LateFieldDescriptor instance.

S must match the type of the LateStruct marker to which this descriptor belongs or the method will panic.

Source

pub unsafe fn typed_unchecked<S: LateStruct>(&self) -> &LateFieldDescriptor<S>

Downcasts the descriptor to a typed LateFieldDescriptor instance.

This operation can be safely performed with RawLateFieldDescriptor::typed.

§Safety

S must match the type of the LateStruct marker to which this descriptor belongs. Failing to do so will not cause immediate undefined behavior but could cause latent undefined behavior if passed to a method expecting the descriptor to belong to a certain LateStruct type.

Trait Implementations§

Source§

impl Debug for RawLateFieldDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.