Re-wrote Provider::sync
This commit is contained in:
parent
c46222c8c7
commit
5c3c5c8090
10 changed files with 256 additions and 69 deletions
15
src/task.rs
15
src/task.rs
|
@ -2,7 +2,7 @@ use chrono::{Utc, DateTime};
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::item::ItemId;
|
||||
use crate::item::VersionTag;
|
||||
use crate::item::SyncStatus;
|
||||
|
||||
/// A to-do task
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
|
@ -12,8 +12,8 @@ pub struct Task {
|
|||
|
||||
/// The last modification date of this task
|
||||
last_modified: DateTime<Utc>,
|
||||
/// The version tag of this item
|
||||
version_tag: VersionTag,
|
||||
/// The sync status of this item
|
||||
sync_status: SyncStatus,
|
||||
|
||||
/// The display name of the task
|
||||
name: String,
|
||||
|
@ -23,12 +23,12 @@ pub struct Task {
|
|||
|
||||
impl Task {
|
||||
/// Create a new Task
|
||||
pub fn new(name: String, id: ItemId, last_modified: DateTime<Utc>, version_tag: VersionTag) -> Self {
|
||||
pub fn new(name: String, id: ItemId, last_modified: DateTime<Utc>, sync_status: SyncStatus) -> Self {
|
||||
Self {
|
||||
id,
|
||||
name,
|
||||
last_modified,
|
||||
version_tag,
|
||||
sync_status,
|
||||
completed: false,
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,10 @@ impl Task {
|
|||
pub fn name(&self) -> &str { &self.name }
|
||||
pub fn completed(&self) -> bool { self.completed }
|
||||
pub fn last_modified(&self) -> DateTime<Utc> { self.last_modified }
|
||||
pub fn version_tag(&self) -> &VersionTag { &self.version_tag }
|
||||
pub fn sync_status(&self) -> &SyncStatus { &self.sync_status }
|
||||
pub fn set_sync_status(&mut self, new_status: SyncStatus) {
|
||||
self.sync_status = new_status;
|
||||
}
|
||||
|
||||
fn update_last_modified(&mut self) {
|
||||
self.last_modified = Utc::now();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue