pub struct RecipeRegistry {
recipes: Vec<UntypedRecipeRef>,
by_key: FxHashMap<Identifier, usize>,
by_type: FxHashMap<Identifier, Vec<usize>>,
allows_registering: bool,
}Expand description
Central storage for recipes of every registered concrete type.
Fields§
§recipes: Vec<UntypedRecipeRef>§by_key: FxHashMap<Identifier, usize>§by_type: FxHashMap<Identifier, Vec<usize>>§allows_registering: boolImplementations§
Source§impl RecipeRegistry
impl RecipeRegistry
pub fn new() -> Self
Sourcepub fn register<D: RecipeMatches<I> + DowncastType, I: RecipeInput>(
&mut self,
recipe: &'static Recipe<D, I>,
)
pub fn register<D: RecipeMatches<I> + DowncastType, I: RecipeInput>( &mut self, recipe: &'static Recipe<D, I>, )
Registers a concrete static recipe.
Sourcepub fn replace<D: RecipeMatches<I> + DowncastType, I: RecipeInput>(
&mut self,
recipe: &'static Recipe<D, I>,
) -> Option<UntypedRecipeRef>
pub fn replace<D: RecipeMatches<I> + DowncastType, I: RecipeInput>( &mut self, recipe: &'static Recipe<D, I>, ) -> Option<UntypedRecipeRef>
Replaces an entry with the same persistent key before freeze.
Sourcepub fn freeze(&mut self, recipe_types: &RecipeTypeRegistry)
pub fn freeze(&mut self, recipe_types: &RecipeTypeRegistry)
Freezes and sorts recipe lookup order by full identifier, matching
Vanilla’s sorted resource loading before RecipeMap construction.
pub fn by_key(&self, key: &Identifier) -> Option<UntypedRecipeRef>
pub fn iter(&self) -> impl Iterator<Item = UntypedRecipeRef> + '_
pub fn by_type<D: RecipeMatches<I> + DowncastType, I: RecipeInput>( &self, recipe_type: &'static RecipeType<D, I>, ) -> TypedRecipeSet<'_, D, I>
Sourcepub fn matching<'registry, D: RecipeMatches<I> + DowncastType, I: RecipeInput>(
&'registry self,
recipe_type: &'static RecipeType<D, I>,
input: &'registry I,
) -> impl Iterator<Item = TypedRecipeRef<D, I>> + 'registry
pub fn matching<'registry, D: RecipeMatches<I> + DowncastType, I: RecipeInput>( &'registry self, recipe_type: &'static RecipeType<D, I>, input: &'registry I, ) -> impl Iterator<Item = TypedRecipeRef<D, I>> + 'registry
Iterates every matching recipe in deterministic key order.
Sourcepub fn find_match<D: RecipeMatches<I> + DowncastType, I: RecipeInput>(
&self,
recipe_type: &'static RecipeType<D, I>,
input: &I,
) -> Option<TypedRecipeRef<D, I>>
pub fn find_match<D: RecipeMatches<I> + DowncastType, I: RecipeInput>( &self, recipe_type: &'static RecipeType<D, I>, input: &I, ) -> Option<TypedRecipeRef<D, I>>
Finds the first matching recipe in deterministic registry order.
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RecipeRegistry
impl !UnwindSafe for RecipeRegistry
impl Freeze for RecipeRegistry
impl Send for RecipeRegistry
impl Sync for RecipeRegistry
impl Unpin for RecipeRegistry
impl UnsafeUnpin for RecipeRegistry
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreWraps this value in an
Arc<SyncMutex<>>