| Crates.io | cooklang-find |
| lib.rs | cooklang-find |
| version | 0.4.0 |
| created_at | 2025-05-21 16:33:22.064873+00 |
| updated_at | 2025-08-28 04:27:40.885963+00 |
| description | Library for finding and managing Cooklang recipes in the filesystem |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1683623 |
| size | 93,991 |
A Rust library for finding and managing Cooklang recipes in the filesystem. This library provides functionality to search, organize, and manage your recipe collection efficiently.
Add this to your Cargo.toml:
[dependencies]
cooklang-find = "0.1.0"
use cooklang_find::get_recipe;
use std::path::Path;
// Search for a recipe in multiple directories
let recipe_dirs = vec![
Path::new("~/recipes"),
Path::new("~/more-recipes")
];
match get_recipe(recipe_dirs, Path::new("pancakes")) {
Ok(Some(recipe)) => println!("Found recipe: {}", recipe.name),
Ok(None) => println!("Recipe not found"),
Err(e) => eprintln!("Error: {}", e),
}
use cooklang_find::build_tree;
use std::path::Path;
// Build a tree structure of your recipe collection
match build_tree(Path::new("~/recipes")) {
Ok(tree) => {
// Access recipes and subdirectories
for (name, node) in tree.children {
if let Some(recipe) = node.recipe {
println!("Found recipe: {}", recipe.name);
} else {
println!("Found directory: {}", name);
}
}
}
Err(e) => eprintln!("Error: {}", e),
}
use cooklang_find::search;
use std::path::Path;
// Search for recipes containing specific text
match search(Path::new("~/recipes"), "pancake") {
Ok(recipes) => {
for recipe in recipes {
println!("Found matching recipe: {}", recipe.name);
}
}
Err(e) => eprintln!("Error: {}", e),
}
The library supports Cooklang recipes with frontmatter metadata. Example:
---
servings: 4
time: 30 min
cuisine: Italian
---
Prepare the @pasta{500%g} by boiling it in @water{2%l}.
Add @salt{1%tsp} to taste.
The library provides custom error types for different scenarios:
FetchError: Issues with finding recipesRecipeEntryError: Problems with recipe parsing or readingTreeError: Errors in building recipe tree structureSearchError: Issues during recipe searchContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.