[][src]Trait libimaghabit::habit::HabitTemplate

pub trait HabitTemplate: Sized {
    fn create_instance_with_date<'a>(
        &mut self,
        store: &'a Store,
        date: NaiveDate
    ) -> Result<FileLockEntry<'a>>;
fn create_instance_today<'a>(
        &mut self,
        store: &'a Store
    ) -> Result<FileLockEntry<'a>>;
fn retrieve_instance_with_date<'a>(
        &mut self,
        store: &'a Store,
        date: NaiveDate
    ) -> Result<FileLockEntry<'a>>;
fn retrieve_instance_today<'a>(
        &mut self,
        store: &'a Store
    ) -> Result<FileLockEntry<'a>>;
fn linked_instances(&self) -> Result<HabitInstanceStoreIdIterator>;
fn next_instance_date_after(
        &self,
        base: &NaiveDateTime
    ) -> Result<Option<NaiveDate>>;
fn next_instance_date(&self) -> Result<Option<NaiveDate>>;
fn is_habit_template(&self) -> Result<bool>;
fn habit_name(&self) -> Result<String>;
fn habit_basedate(&self) -> Result<String>;
fn habit_recur_spec(&self) -> Result<String>;
fn habit_comment(&self) -> Result<String>;
fn habit_until_date(&self) -> Result<Option<String>>;
fn instance_exists_for_date(&self, date: NaiveDate) -> Result<bool>;
fn instance_id_for(
        habit_name: &str,
        habit_date: NaiveDate
    ) -> Result<StoreId>; }

A HabitTemplate is a "template" of a habit. A user may define a habit "Eat vegetable". If the user ate a vegetable, she should create a HabitInstance from the Habit with the appropriate date (and optionally a comment) set.

Required methods

fn create_instance_with_date<'a>(
    &mut self,
    store: &'a Store,
    date: NaiveDate
) -> Result<FileLockEntry<'a>>

Create an instance from this habit template

By default creates an instance with the name of the template, the current time and the current date and copies the comment from the template to the instance.

It uses Store::retrieve() underneath. So if there is already an instance for the day passed, this will simply return the instance.

fn create_instance_today<'a>(
    &mut self,
    store: &'a Store
) -> Result<FileLockEntry<'a>>

Shortcut for calling Self::create_instance_with_date() with an instance of ::chrono::Local::today().naive_local().

fn retrieve_instance_with_date<'a>(
    &mut self,
    store: &'a Store,
    date: NaiveDate
) -> Result<FileLockEntry<'a>>

Same as HabitTemplate::create_instance_with_date() but uses Store::retrieve internally.

fn retrieve_instance_today<'a>(
    &mut self,
    store: &'a Store
) -> Result<FileLockEntry<'a>>

Same as HabitTemplate::create_instance_today() but uses Store::retrieve internally.

fn linked_instances(&self) -> Result<HabitInstanceStoreIdIterator>

Get instances for this template

fn next_instance_date_after(
    &self,
    base: &NaiveDateTime
) -> Result<Option<NaiveDate>>

Get the date of the next date when the habit should be done

fn next_instance_date(&self) -> Result<Option<NaiveDate>>

Get the date of the next date when the habit should be done

fn is_habit_template(&self) -> Result<bool>

Check whether the instance is a habit by checking its headers for the habit data

fn habit_name(&self) -> Result<String>

fn habit_basedate(&self) -> Result<String>

fn habit_recur_spec(&self) -> Result<String>

fn habit_comment(&self) -> Result<String>

fn habit_until_date(&self) -> Result<Option<String>>

fn instance_exists_for_date(&self, date: NaiveDate) -> Result<bool>

fn instance_id_for(habit_name: &str, habit_date: NaiveDate) -> Result<StoreId>

Create a StoreId for a habit name and a date the habit should be instantiated for

Loading content...

Implementations on Foreign Types

impl HabitTemplate for Entry[src]

fn next_instance_date(&self) -> Result<Option<NaiveDate>>[src]

Get the date of the next date when the habit should be done

fn is_habit_template(&self) -> Result<bool>[src]

Check whether the instance is a habit by checking its headers for the habit data

Loading content...

Implementors

Loading content...