aboutsummaryrefslogtreecommitdiff
path: root/src/imap/command/anonymous.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-01 09:34:13 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-01 09:34:13 +0100
commitd2c3b641fea6106d0fa2a7940abbc026e003f707 (patch)
tree5c79d70cb8d6bf8c0be59edd2094855e2cd86315 /src/imap/command/anonymous.rs
parent6e20778f74a89d4b7a9b2c9cfca5bb2907bb0d22 (diff)
downloadaerogramme-d2c3b641fea6106d0fa2a7940abbc026e003f707.tar.gz
aerogramme-d2c3b641fea6106d0fa2a7940abbc026e003f707.zip
WIP rewrite
Diffstat (limited to 'src/imap/command/anonymous.rs')
-rw-r--r--src/imap/command/anonymous.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/imap/command/anonymous.rs b/src/imap/command/anonymous.rs
index 6ba19cf..9f4563f 100644
--- a/src/imap/command/anonymous.rs
+++ b/src/imap/command/anonymous.rs
@@ -1,8 +1,7 @@
use anyhow::{Error, Result};
-use boitalettres::proto::{res::body::Data as Body, Request, Response};
-use imap_codec::types::command::CommandBody;
-use imap_codec::types::core::AString;
-use imap_codec::types::response::{Capability, Data, Status};
+use imap_codec::imap_types::command::{Command, CommandBody};
+use imap_codec::imap_types::core::AString;
+use imap_codec::imap_types::response::{Capability, Data, Status, CommandContinuationRequest};
use crate::imap::flow;
use crate::login::ArcLoginProvider;
@@ -11,12 +10,12 @@ use crate::mail::user::User;
//--- dispatching
pub struct AnonymousContext<'a> {
- pub req: &'a Request,
+ pub req: &'a Command<'static>,
pub login_provider: Option<&'a ArcLoginProvider>,
}
-pub async fn dispatch(ctx: AnonymousContext<'_>) -> Result<(Response, flow::Transition)> {
- match &ctx.req.command.body {
+pub async fn dispatch(ctx: AnonymousContext<'_>) -> Result<(Status, flow::Transition)> {
+ match &ctx.req.body {
CommandBody::Noop => Ok((Response::ok("Noop completed.")?, flow::Transition::None)),
CommandBody::Capability => ctx.capability().await,
CommandBody::Logout => ctx.logout().await,
@@ -31,7 +30,7 @@ pub async fn dispatch(ctx: AnonymousContext<'_>) -> Result<(Response, flow::Tran
//--- Command controllers, private
impl<'a> AnonymousContext<'a> {
- async fn capability(self) -> Result<(Response, flow::Transition)> {
+ async fn capability(self) -> Result<(Status, flow::Transition)> {
let capabilities = vec![Capability::Imap4Rev1, Capability::Idle];
let res = Response::ok("Server capabilities")?.with_body(Data::Capability(capabilities));
Ok((res, flow::Transition::None))
@@ -41,7 +40,7 @@ impl<'a> AnonymousContext<'a> {
self,
username: &AString,
password: &AString,
- ) -> Result<(Response, flow::Transition)> {
+ ) -> Result<(Status, flow::Transition)> {
let (u, p) = (
String::try_from(username.clone())?,
String::try_from(password.clone())?,
@@ -81,7 +80,7 @@ impl<'a> AnonymousContext<'a> {
// C: 10 logout
// S: * BYE Logging out
// S: 10 OK Logout completed.
- async fn logout(self) -> Result<(Response, flow::Transition)> {
+ async fn logout(self) -> Result<(Status, flow::Transition)> {
// @FIXME we should implement From<Vec<Status>> and From<Vec<ImapStatus>> in
// boitalettres/src/proto/res/body.rs
Ok((