More Results in traits
This commit is contained in:
parent
def17b6218
commit
cbffef8b97
3 changed files with 7 additions and 7 deletions
|
@ -97,8 +97,8 @@ impl PartialCalendar for CachedCalendar {
|
||||||
Ok(map)
|
Ok(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_item_ids(&mut self) -> HashSet<ItemId> {
|
async fn get_item_ids(&self) -> Result<HashSet<ItemId>, Box<dyn Error>> {
|
||||||
self.items.keys().cloned().collect()
|
Ok(self.items.keys().cloned().collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_item_by_id_mut<'a>(&'a mut self, id: &ItemId) -> Option<&'a mut Item> {
|
async fn get_item_by_id_mut<'a>(&'a mut self, id: &ItemId) -> Option<&'a mut Item> {
|
||||||
|
|
|
@ -83,7 +83,7 @@ where
|
||||||
Some(date) => cal_local.get_items_deleted_since(date).await?,
|
Some(date) => cal_local.get_items_deleted_since(date).await?,
|
||||||
};
|
};
|
||||||
if last_sync.is_some() {
|
if last_sync.is_some() {
|
||||||
let server_deletions = cal_server.find_deletions_from(cal_local.get_item_ids().await).await;
|
let server_deletions = cal_server.find_deletions_from(cal_local.get_item_ids().await?).await?;
|
||||||
for server_del_id in server_deletions {
|
for server_del_id in server_deletions {
|
||||||
// Even in case of conflicts, "the server always wins", so it is safe to remove tasks from the local cache as soon as now
|
// Even in case of conflicts, "the server always wins", so it is safe to remove tasks from the local cache as soon as now
|
||||||
if let Err(err) = cal_local.delete_item(&server_del_id).await {
|
if let Err(err) = cal_local.delete_item(&server_del_id).await {
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub trait PartialCalendar {
|
||||||
-> Result<HashMap<ItemId, &Item>, Box<dyn Error>>;
|
-> Result<HashMap<ItemId, &Item>, Box<dyn Error>>;
|
||||||
|
|
||||||
/// Get the IDs of all current items in this calendar
|
/// Get the IDs of all current items in this calendar
|
||||||
async fn get_item_ids(&mut self) -> HashSet<ItemId>;
|
async fn get_item_ids(&self) -> Result<HashSet<ItemId>, Box<dyn Error>>;
|
||||||
|
|
||||||
/// Returns a particular item
|
/// Returns a particular item
|
||||||
async fn get_item_by_id_mut<'a>(&'a mut self, id: &ItemId) -> Option<&'a mut Item>;
|
async fn get_item_by_id_mut<'a>(&'a mut self, id: &ItemId) -> Option<&'a mut Item>;
|
||||||
|
@ -68,9 +68,9 @@ pub trait PartialCalendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finds the IDs of the items that are missing compared to a reference set
|
/// Finds the IDs of the items that are missing compared to a reference set
|
||||||
async fn find_deletions_from(&mut self, reference_set: HashSet<ItemId>) -> HashSet<ItemId> {
|
async fn find_deletions_from(&self, reference_set: HashSet<ItemId>) -> Result<HashSet<ItemId>, Box<dyn Error>> {
|
||||||
let current_items = self.get_item_ids().await;
|
let current_items = self.get_item_ids().await?;
|
||||||
reference_set.difference(¤t_items).map(|id| id.clone()).collect()
|
Ok(reference_set.difference(¤t_items).map(|id| id.clone()).collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue