pub struct Storage { /* private fields */ }Expand description
Storage for meal data.
Implementations§
Source§impl Storage
impl Storage
Sourcepub fn open(path: &str) -> Result<Self>
pub fn open(path: &str) -> Result<Self>
Opens a storage in the given path. Given a path to a non-existing file, this will try to create a new storage in that path and then open it.
Example:
use libmrot::Storage;
let storage = Storage::open("./path/to/my_storage").unwrap();For testing purposes the special path :memory: gives access to an in-memory storage which will
live as long as the instance of this struct.
Example:
use libmrot::Storage;
let test_storage = Storage::open(":memory:").unwrap();Sourcepub fn add_meal_on_dates(&self, meal: &str, dates: &Vec<String>) -> Result<()>
pub fn add_meal_on_dates(&self, meal: &str, dates: &Vec<String>) -> Result<()>
Adds a meal on the given dates to the storage.
Sourcepub fn when(&self, meal: &str) -> Result<Vec<NaiveDate>>
pub fn when(&self, meal: &str) -> Result<Vec<NaiveDate>>
Show on what dates a meal was recorded.
Sourcepub fn show(&self, date_range: &str) -> Result<Vec<MealRecord>>
pub fn show(&self, date_range: &str) -> Result<Vec<MealRecord>>
Show what meals were recorded in the given date range.
Sourcepub fn what(
&self,
number: usize,
ignore: &Vec<String>,
look_ahead: &Vec<NaiveDate>,
) -> Result<Vec<MealRecord>>
pub fn what( &self, number: usize, ignore: &Vec<String>, look_ahead: &Vec<NaiveDate>, ) -> Result<Vec<MealRecord>>
Suggest meals to cook. Returns MealRecords of the suggested meals and the last dates when they were cooked. Ignores the meals in the ignore vector and meals recorded on the dates in the look_ahead vector.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Storage
impl !RefUnwindSafe for Storage
impl Send for Storage
impl !Sync for Storage
impl Unpin for Storage
impl !UnwindSafe for Storage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more