diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-22 17:25:04 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-22 17:25:04 +0200 |
commit | ac974184def76fefba6c36c5c9e0ff0298f860ff (patch) | |
tree | 2df5bdce347e0fc410a48d0c6f1dbdd49e29608b /src/imap/command/selected.rs | |
parent | 50b19729878938b63ea33d4dbdcfd254b4462110 (diff) | |
download | aerogramme-ac974184def76fefba6c36c5c9e0ff0298f860ff.tar.gz aerogramme-ac974184def76fefba6c36c5c9e0ff0298f860ff.zip |
Refactor selected
Diffstat (limited to 'src/imap/command/selected.rs')
-rw-r--r-- | src/imap/command/selected.rs | 30 |
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)) } } -*/ |