ExtractionMetadata

Enum ExtractionMetadata 

Source
pub enum ExtractionMetadata {
    Target {
        type_id: TypeId,
        offset: usize,
        identifier: &'static str,
    },
    Nested {
        type_id: TypeId,
        offset: usize,
        nested: &'static [ExtractionMetadata],
        identifier: &'static str,
    },
}
Expand description

Metadata describing how to extract types from an entity structure.

Variants§

§

Target

Direct target at a specific offset.

Fields

§type_id: TypeId
§offset: usize
§identifier: &'static str
§

Nested

Nested extractable type with its own metadata.

Fields

§type_id: TypeId
§offset: usize
§nested: &'static [ExtractionMetadata]
§identifier: &'static str

Implementations§

Source§

impl ExtractionMetadata

Source

pub const fn new<T: Extractable>(offset: usize) -> Self

Create metadata for a direct target type.

Source

pub const fn new_nested<T: Extractable>( offset: usize, nested: &'static [ExtractionMetadata], ) -> Self

Create metadata for a nested extractable type.

Source

pub const fn is_has<List: Extractable, Target: Extractable>() -> bool

Compile-time check whether List contains Target in its extraction metadata.

This function is designed to be called at the beginning of functions that may panic. Since const panics don’t support #[track_caller], it’s best to place this check at the start of public API functions for better error reporting.

§Implementation Note

Uses string-based identifier comparison instead of TypeId::eq() because:

  • TypeId::eq() is not yet stable in const context (as of Rust 1.83)
  • type_name() is also not const-stable
  • String comparison with IDENTIFIER (module_path + struct_name) provides the same uniqueness guarantee while being const-evaluable
Source

pub const fn has_val(&self, identifier: &str) -> bool

Source

pub fn flatten(list: &[ExtractionMetadata]) -> FxHashMap<TypeId, usize>

Flatten nested metadata into a single HashMap of type -> offset mappings.

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.