aboutsummaryrefslogtreecommitdiff
path: root/src/imap/command
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-06-28 10:49:28 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-06-28 10:49:28 +0200
commit36bbc2138bceb0c80a306f8c225e340d6fbd5470 (patch)
tree9592daf96a58a61b16337968b662e85199e0e158 /src/imap/command
parent927b461f25e8202a33fadc1f823d4feed6282f60 (diff)
downloadaerogramme-36bbc2138bceb0c80a306f8c225e340d6fbd5470.tar.gz
aerogramme-36bbc2138bceb0c80a306f8c225e340d6fbd5470.zip
cargo fmt + implement noop
Diffstat (limited to 'src/imap/command')
-rw-r--r--src/imap/command/anonymous.rs5
-rw-r--r--src/imap/command/authenticated.rs52
-rw-r--r--src/imap/command/selected.rs5
3 files changed, 21 insertions, 41 deletions
diff --git a/src/imap/command/anonymous.rs b/src/imap/command/anonymous.rs
index a2f2260..8de27cb 100644
--- a/src/imap/command/anonymous.rs
+++ b/src/imap/command/anonymous.rs
@@ -11,11 +11,12 @@ use crate::imap::session::InnerContext;
pub async fn dispatch<'a>(ctx: InnerContext<'a>) -> Result<(Response, flow::Transition)> {
match &ctx.req.command.body {
+ CommandBody::Noop => Ok((Response::ok("Noop completed.")?, flow::Transition::No)),
CommandBody::Capability => capability(ctx).await,
CommandBody::Login { username, password } => login(ctx, username, password).await,
_ => Ok((
Response::no("This command is not available in the ANONYMOUS state.")?,
- flow::Transition::No
+ flow::Transition::No,
)),
}
}
@@ -55,6 +56,6 @@ async fn login<'a>(
tracing::info!(username=%u, "connected");
Ok((
Response::ok("Completed")?,
- flow::Transition::Authenticate(user)
+ flow::Transition::Authenticate(user),
))
}
diff --git a/src/imap/command/authenticated.rs b/src/imap/command/authenticated.rs
index 85c1c82..4ba4968 100644
--- a/src/imap/command/authenticated.rs
+++ b/src/imap/command/authenticated.rs
@@ -1,5 +1,5 @@
use anyhow::{anyhow, Error, Result};
-use boitalettres::proto::{Response, res::body::Data as Body};
+use boitalettres::proto::{res::body::Data as Body, Response};
use imap_codec::types::command::CommandBody;
use imap_codec::types::core::Atom;
use imap_codec::types::flag::Flag;
@@ -12,11 +12,11 @@ use crate::imap::session::InnerContext;
use crate::mail::Mailbox;
const DEFAULT_FLAGS: [Flag; 5] = [
- Flag::Seen,
- Flag::Answered,
- Flag::Flagged,
- Flag::Deleted,
- Flag::Draft,
+ Flag::Seen,
+ Flag::Answered,
+ Flag::Flagged,
+ Flag::Deleted,
+ Flag::Draft,
];
pub async fn dispatch<'a>(
@@ -52,10 +52,7 @@ impl<'a> StateContext<'a> {
reference: &MailboxCodec,
mailbox_wildcard: &ListMailbox,
) -> Result<(Response, flow::Transition)> {
- Ok((
- Response::bad("Not implemented")?,
- flow::Transition::No,
- ))
+ Ok((Response::bad("Not implemented")?, flow::Transition::No))
}
async fn list(
@@ -63,10 +60,7 @@ impl<'a> StateContext<'a> {
reference: &MailboxCodec,
mailbox_wildcard: &ListMailbox,
) -> Result<(Response, flow::Transition)> {
- Ok((
- Response::bad("Not implemented")?,
- flow::Transition::No,
- ))
+ Ok((Response::bad("Not implemented")?, flow::Transition::No))
}
/*
@@ -128,37 +122,25 @@ impl<'a> StateContext<'a> {
res.push(Body::Data(Data::Flags(flags.clone())));
- let uid_validity = Status::ok(
- None,
- Some(Code::UidValidity(sum.validity)),
- "UIDs valid"
- )
+ let uid_validity = Status::ok(None, Some(Code::UidValidity(sum.validity)), "UIDs valid")
.map_err(Error::msg)?;
res.push(Body::Status(uid_validity));
- let next_uid = Status::ok(
- None,
- Some(Code::UidNext(sum.next)),
- "Predict next UID"
- ).map_err(Error::msg)?;
+ let next_uid = Status::ok(None, Some(Code::UidNext(sum.next)), "Predict next UID")
+ .map_err(Error::msg)?;
res.push(Body::Status(next_uid));
if let Some(unseen) = sum.unseen {
- let status_unseen = Status::ok(
- None,
- Some(Code::Unseen(unseen.clone())),
- "First unseen UID",
- )
- .map_err(Error::msg)?;
+ let status_unseen =
+ Status::ok(None, Some(Code::Unseen(unseen.clone())), "First unseen UID")
+ .map_err(Error::msg)?;
res.push(Body::Status(status_unseen));
}
flags.push(Flag::Permanent);
- let permanent_flags = Status::ok(
- None,
- Some(Code::PermanentFlags(flags)),
- "Flags permitted",
- ).map_err(Error::msg)?;
+ let permanent_flags =
+ Status::ok(None, Some(Code::PermanentFlags(flags)), "Flags permitted")
+ .map_err(Error::msg)?;
res.push(Body::Status(permanent_flags));
Ok((
diff --git a/src/imap/command/selected.rs b/src/imap/command/selected.rs
index e013eaa..cf0b71b 100644
--- a/src/imap/command/selected.rs
+++ b/src/imap/command/selected.rs
@@ -47,9 +47,6 @@ impl<'a> StateContext<'a> {
attributes: &MacroOrFetchAttributes,
uid: &bool,
) -> Result<(Response, flow::Transition)> {
- Ok((
- Response::bad("Not implemented")?,
- flow::Transition::No,
- ))
+ Ok((Response::bad("Not implemented")?, flow::Transition::No))
}
}