aboutsummaryrefslogtreecommitdiff
path: root/src/mail/query.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-08 21:32:55 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-08 21:32:55 +0100
commit056f8ea14c373b8c0009ed4827a553ac2e27815b (patch)
tree81e3bfd1419feb87f4f44513e4ee3d0e34ecd20e /src/mail/query.rs
parenta90f425d32af866974eec58b43c02f302ae3376a (diff)
downloadaerogramme-056f8ea14c373b8c0009ed4827a553ac2e27815b.tar.gz
aerogramme-056f8ea14c373b8c0009ed4827a553ac2e27815b.zip
Better choose wether or not a body is required
Diffstat (limited to 'src/mail/query.rs')
-rw-r--r--src/mail/query.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/mail/query.rs b/src/mail/query.rs
index a8a23b2..0838800 100644
--- a/src/mail/query.rs
+++ b/src/mail/query.rs
@@ -31,8 +31,12 @@ impl QueryScope {
impl<'a, 'b> Query<'a, 'b> {
pub async fn fetch(&self) -> Result<Vec<QueryResult>> {
match self.scope {
- QueryScope::Index => Ok(self.emails.iter().map(|&uuid| QueryResult::IndexResult { uuid }).collect()),
- QueryScope::Partial =>self.partial().await,
+ QueryScope::Index => Ok(self
+ .emails
+ .iter()
+ .map(|&uuid| QueryResult::IndexResult { uuid })
+ .collect()),
+ QueryScope::Partial => self.partial().await,
QueryScope::Full => self.full().await,
}
}
@@ -44,9 +48,7 @@ impl<'a, 'b> Query<'a, 'b> {
let result = meta
.into_iter()
.zip(self.emails.iter())
- .map(|(metadata, &uuid)| {
- QueryResult::PartialResult { uuid, metadata }
- })
+ .map(|(metadata, &uuid)| QueryResult::PartialResult { uuid, metadata })
.collect::<Vec<_>>();
Ok(result)
@@ -125,20 +127,14 @@ impl QueryResult {
fn into_partial(self, metadata: MailMeta) -> Option<Self> {
match self {
- Self::IndexResult { uuid } => Some(Self::PartialResult {
- uuid,
- metadata,
- }),
+ Self::IndexResult { uuid } => Some(Self::PartialResult { uuid, metadata }),
_ => None,
}
}
fn into_full(self, content: Vec<u8>) -> Option<Self> {
match self {
- Self::PartialResult {
- uuid,
- metadata,
- } => Some(Self::FullResult {
+ Self::PartialResult { uuid, metadata } => Some(Self::FullResult {
uuid,
metadata,
content,