pub trait RecipeRegistryHandle {
// Required methods
fn add_shaped(&mut self, recipe: OwnedShapedRecipe);
fn add_shapeless(&mut self, recipe: OwnedShapelessRecipe);
fn remove_by_id(&mut self, id: &RecipeId) -> Option<Recipe>;
fn remove_by_result(&mut self, result_id: i32) -> Vec<RecipeId>;
fn clear(&mut self) -> Vec<RecipeId>;
fn contains(&self, id: &RecipeId) -> bool;
fn find_by_id(&self, id: &RecipeId) -> Option<Recipe>;
fn shaped_count(&self) -> usize;
fn shapeless_count(&self) -> usize;
}Expand description
Long-lived handle to the recipe registry runtime.
Implemented by basalt_recipes::RecipeRegistry (production) and
mock types (tests). Plugins receive a &mut dyn RecipeRegistryHandle indirectly via
RecipeRegistrar.
Methods mirror the inherent API of RecipeRegistry — see each
method’s doc for semantics.
Required Methods§
Sourcefn add_shaped(&mut self, recipe: OwnedShapedRecipe)
fn add_shaped(&mut self, recipe: OwnedShapedRecipe)
Inserts a shaped recipe.
The caller is responsible for id uniqueness. No duplicate checking is performed.
Sourcefn add_shapeless(&mut self, recipe: OwnedShapelessRecipe)
fn add_shapeless(&mut self, recipe: OwnedShapelessRecipe)
Inserts a shapeless recipe.
The caller is responsible for sorting recipe.ingredients
ascending and for id uniqueness.
Sourcefn remove_by_id(&mut self, id: &RecipeId) -> Option<Recipe>
fn remove_by_id(&mut self, id: &RecipeId) -> Option<Recipe>
Removes the recipe with the given id.
Searches both shaped and shapeless registries. Returns the
removed recipe or None if not present.
Sourcefn remove_by_result(&mut self, result_id: i32) -> Vec<RecipeId>
fn remove_by_result(&mut self, result_id: i32) -> Vec<RecipeId>
Removes every recipe (shaped and shapeless) producing the given
result_id.
Returns the ids of the removed recipes in registry order — first shaped, then shapeless.
Sourcefn clear(&mut self) -> Vec<RecipeId>
fn clear(&mut self) -> Vec<RecipeId>
Removes every recipe and returns their ids.
Returned in registry order — first shaped, then shapeless.
Sourcefn contains(&self, id: &RecipeId) -> bool
fn contains(&self, id: &RecipeId) -> bool
Returns true if a recipe with the given id is registered.
Sourcefn find_by_id(&self, id: &RecipeId) -> Option<Recipe>
fn find_by_id(&self, id: &RecipeId) -> Option<Recipe>
Returns a clone of the recipe with the given id, or None.
Searches shaped recipes first then shapeless.
Sourcefn shaped_count(&self) -> usize
fn shaped_count(&self) -> usize
Returns the number of registered shaped recipes.
Sourcefn shapeless_count(&self) -> usize
fn shapeless_count(&self) -> usize
Returns the number of registered shapeless recipes.