Skip to main content

read

Function read 

Source
pub fn read(
    ctx: &Context,
    req: ReadRequest,
) -> Result<Outcome<ReadResult>, CoreError>
Expand description

Read a recipe, scale it, and report anything the parser had to say.

A RecipeSource::Path is resolved against Context::base_path, trying both .cook and .menu when the name carries no extension. A RecipeSource::Content is parsed as given and never touches the filesystem; its name is only a fallback for ReadResult::title, used when the recipe declares no title of its own.

§Errors

  • CoreError::RecipeNotFound if no file matches the given path or name. Reserved for genuine absence — a file that exists but cannot be opened is an CoreError::Io, since telling a caller a file it can see is “not found” sends it looking for the wrong problem.
  • CoreError::Io if the file is found but cannot be read or its front matter cannot be understood. The underlying cause is in source.
  • CoreError::Parse if the recipe has parse errors. Its name is the recipe’s path, matching the file the rendered report points at.
  • CoreError::InvalidScale if the scale is not finite.