Skip to main content

search

Function search 

Source
pub fn search(
    ctx: &Context,
    req: SearchRequest,
) -> Result<Outcome<Vec<SearchHit>>, CoreError>
Expand description

Search the recipes under req’s root, best match first.

The root is SearchRequest::base_dir, or Context::base_path when that is unset. Nothing else on the context is consulted. A root that does not exist is not an error: there is simply nothing under it to match.

Every term must match; see the module documentation.

§Errors

  • CoreError::Search if the root cannot be searched at all, which in practice means its name contains glob syntax.
  • CoreError::Io if a file under the root turned up in the walk but could not be read, or its front matter could not be understood. One such file fails the whole search rather than being skipped — that is cooklang-find’s behaviour and this crate does not paper over it.