aboutsummaryrefslogtreecommitdiff
path: root/src/imap/command/selected.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-06-22 17:25:04 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-06-22 17:25:04 +0200
commitac974184def76fefba6c36c5c9e0ff0298f860ff (patch)
tree2df5bdce347e0fc410a48d0c6f1dbdd49e29608b /src/imap/command/selected.rs
parent50b19729878938b63ea33d4dbdcfd254b4462110 (diff)
downloadaerogramme-ac974184def76fefba6c36c5c9e0ff0298f860ff.tar.gz
aerogramme-ac974184def76fefba6c36c5c9e0ff0298f860ff.zip
Refactor selected
Diffstat (limited to 'src/imap/command/selected.rs')
-rw-r--r--src/imap/command/selected.rs30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/imap/command/selected.rs b/src/imap/command/selected.rs
index 93592c1..a068fab 100644
--- a/src/imap/command/selected.rs
+++ b/src/imap/command/selected.rs
@@ -9,26 +9,25 @@ use imap_codec::types::sequence::SequenceSet;
use crate::imap::command::authenticated;
use crate::imap::session::InnerContext;
-use crate::imap::flow::User;
+use crate::imap::flow;
use crate::mailbox::Mailbox;
-/*
-pub async fn dispatch<'a>(inner: InnerContext<'a>, user: &'a User, mailbox: &'a Mailbox) -> Result<Response> {
- let ctx = StateContext { inner, user, mailbox, tag: &inner.req.tag };
- match ctx.inner.req.body {
+pub async fn dispatch<'a>(inner: InnerContext<'a>, user: &'a flow::User, mailbox: &'a Mailbox) -> Result<(Response, flow::Transition)> {
+ let ctx = StateContext { tag: &inner.req.tag, inner, user, mailbox };
+
+ match &ctx.inner.req.body {
CommandBody::Fetch { sequence_set, attributes, uid, } => ctx.fetch(sequence_set, attributes, uid).await,
- _ => authenticated::dispatch(inner, user).await,
+ _ => authenticated::dispatch(ctx.inner, user).await,
}
}
-*/
+
// --- PRIVATE ---
-/*
struct StateContext<'a> {
inner: InnerContext<'a>,
- user: &'a User,
+ user: &'a flow::User,
mailbox: &'a Mailbox,
tag: &'a Tag,
}
@@ -37,13 +36,12 @@ struct StateContext<'a> {
impl<'a> StateContext<'a> {
pub async fn fetch(
&self,
- sequence_set: SequenceSet,
- attributes: MacroOrFetchAttributes,
- uid: bool,
- ) -> Result<Response> {
- Ok(vec![
+ sequence_set: &SequenceSet,
+ attributes: &MacroOrFetchAttributes,
+ uid: &bool,
+ ) -> Result<(Response, flow::Transition)> {
+ Ok((vec![
ImapRes::Status(Status::bad(Some(self.tag.clone()), None, "Not implemented").map_err(Error::msg)?),
- ])
+ ], flow::Transition::No))
}
}
-*/