IMAP mailbox synchronization

This commit is contained in:
Mauro D
2023-06-22 17:29:39 +00:00
parent 5fda550642
commit e1c3190b48
23 changed files with 1849 additions and 91 deletions

View File

@@ -150,4 +150,47 @@ impl Store {
.await
}
}
pub async fn index_values<T: Sync + Send + 'static>(
&self,
mut acc: T,
account_id: u32,
collection: impl Into<u8>,
field: impl Into<u8>,
ascending: bool,
cb: impl Fn(&mut T, u32, &[u8]) -> crate::Result<bool> + Sync + Send + 'static,
) -> crate::Result<T> {
let collection = collection.into();
let field = field.into();
#[cfg(not(feature = "is_sync"))]
{
self.read_transaction()
.await?
.sort_index(
account_id,
collection,
field,
ascending,
|value, document_id| cb(&mut acc, document_id, value).unwrap_or(false),
)
.await
.map(|_| acc)
}
#[cfg(feature = "is_sync")]
{
let trx = self.read_transaction()?;
self.spawn_worker(move || {
trx.sort_index(
account_id,
collection,
field,
ascending,
|value, document_id| cb(&mut acc, document_id, value).unwrap_or(false),
)
.map(|_| acc)
})
.await
}
}
}

View File

@@ -64,7 +64,7 @@ impl Store {
account_id: u32,
collection: impl Into<u8>,
query: Query,
) -> crate::Result<Option<Changes>> {
) -> crate::Result<Changes> {
let collection = collection.into();
let (is_inclusive, from_change_id, to_change_id) = match query {
Query::All => (true, 0, u64::MAX),
@@ -121,7 +121,7 @@ impl Store {
};
}
Ok(Some(changelog))
Ok(changelog)
}
}