Skip to main content

RecipeRegistryHandle

Trait RecipeRegistryHandle 

Source
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§

Source

fn add_shaped(&mut self, recipe: OwnedShapedRecipe)

Inserts a shaped recipe.

The caller is responsible for id uniqueness. No duplicate checking is performed.

Source

fn add_shapeless(&mut self, recipe: OwnedShapelessRecipe)

Inserts a shapeless recipe.

The caller is responsible for sorting recipe.ingredients ascending and for id uniqueness.

Source

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.

Source

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.

Source

fn clear(&mut self) -> Vec<RecipeId>

Removes every recipe and returns their ids.

Returned in registry order — first shaped, then shapeless.

Source

fn contains(&self, id: &RecipeId) -> bool

Returns true if a recipe with the given id is registered.

Source

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.

Source

fn shaped_count(&self) -> usize

Returns the number of registered shaped recipes.

Source

fn shapeless_count(&self) -> usize

Returns the number of registered shapeless recipes.

Implementors§