2021-02-24 17:38:08 +01:00
use serde ::{ Deserialize , Serialize } ;
2021-02-21 23:45:51 +01:00
pub type TaskId = String ; // This is an HTML "etag"
2021-02-19 07:58:53 +01:00
2021-02-18 12:02:04 +01:00
/// A to-do task
2021-02-24 17:38:08 +01:00
#[ derive(Clone, Debug, PartialEq, Serialize, Deserialize) ]
2021-02-18 12:02:04 +01:00
pub struct Task {
2021-02-19 07:58:53 +01:00
id : TaskId ,
2021-02-18 12:02:04 +01:00
name : String ,
2021-02-20 00:10:05 +01:00
completed : bool ,
2021-02-18 12:02:04 +01:00
}
impl Task {
2021-02-21 23:45:51 +01:00
pub fn id ( & self ) -> & TaskId { & self . id }
2021-02-20 00:10:05 +01:00
pub fn name ( & self ) -> & str { & self . name }
2021-02-18 12:02:04 +01:00
pub fn completed ( & self ) -> bool { self . completed }
pub fn set_completed ( & mut self ) {
// TODO: either require a reference to the DataSource, so that it is aware
// or change a flag here, and the DataSource will be able to check the flags of all its content (but then the Calendar should only give a reference/Arc, not a clone)
}
}