pub fn recipes(
ctx: &Context,
req: RecipesRequest,
) -> Result<Outcome<RecipeMatches>, CoreError>Expand description
Work out which recipes under Context::base_path the pantry can cook.
An ingredient counts as in stock when its name matches a pantry item’s,
compared lowercased and otherwise exactly — no unit or quantity is
considered, so a recipe needing a kilo of flour matches a pantry holding a
gram of it. References to other recipes are ignored, and so are optional
ingredients (@?chives): a recipe whose only absent ingredients are
optional is a full match. A recipe left with no ingredients at all matches
nothing. See [required_ingredients] for what else is left out.
Recipes are found by walking the collection, .menu files included. A
recipe that cannot be read or parsed is left out, with a warning in
Outcome::diagnostics naming it — it is not counted as a match or a
miss. Warnings from recipes that did parse are not reported here, because
they cannot change the answer; doctor::validate is the command for those.
§Errors
- As
load, since this needs the pantry. CoreError::Searchif the collection cannot be walked, andCoreError::Ioif a file in it cannot be listed — asdoctor::validate.