aboutsummaryrefslogtreecommitdiff
path: root/src/imap/mod.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-18 18:03:21 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-18 18:03:21 +0100
commit2c5adc8f166c6117ece353376b9071f5e30857b1 (patch)
tree1590c1277342734ee6f06b1a388c0fc63ecd8acf /src/imap/mod.rs
parent43b668531f060a2c0f950da96b363b2ea7cf4e06 (diff)
downloadaerogramme-2c5adc8f166c6117ece353376b9071f5e30857b1.tar.gz
aerogramme-2c5adc8f166c6117ece353376b9071f5e30857b1.zip
reformat code
Diffstat (limited to 'src/imap/mod.rs')
-rw-r--r--src/imap/mod.rs42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/imap/mod.rs b/src/imap/mod.rs
index c50c3fc..40c4d4f 100644
--- a/src/imap/mod.rs
+++ b/src/imap/mod.rs
@@ -15,23 +15,23 @@ mod session;
use std::net::SocketAddr;
-use anyhow::{Result, bail};
+use anyhow::{bail, Result};
use futures::stream::{FuturesUnordered, StreamExt};
use tokio::net::TcpListener;
-use tokio::sync::watch;
use tokio::sync::mpsc;
+use tokio::sync::watch;
+use imap_codec::imap_types::response::{Code, CommandContinuationRequest, Response, Status};
use imap_codec::imap_types::{core::Text, response::Greeting};
use imap_flow::server::{ServerFlow, ServerFlowEvent, ServerFlowOptions};
use imap_flow::stream::AnyStream;
-use imap_codec::imap_types::response::{Code, Response, CommandContinuationRequest, Status};
-use crate::imap::response::{Body, ResponseOrIdle};
-use crate::imap::session::Instance;
-use crate::imap::request::Request;
use crate::config::ImapConfig;
use crate::imap::capability::ServerCapability;
+use crate::imap::request::Request;
+use crate::imap::response::{Body, ResponseOrIdle};
+use crate::imap::session::Instance;
use crate::login::ArcLoginProvider;
/// Server is a thin wrapper to register our Services in BàL
@@ -97,10 +97,10 @@ impl Server {
}
}
+use std::sync::Arc;
use tokio::sync::mpsc::*;
-use tokio_util::bytes::BytesMut;
use tokio::sync::Notify;
-use std::sync::Arc;
+use tokio_util::bytes::BytesMut;
enum LoopMode {
Quit,
Interactive,
@@ -123,10 +123,10 @@ impl NetLoop {
Ok(nl) => {
tracing::debug!(addr=?addr, "netloop successfully initialized");
nl
- },
+ }
Err(e) => {
tracing::error!(addr=?addr, err=?e, "netloop can not be initialized, closing session");
- return
+ return;
}
};
@@ -153,10 +153,10 @@ impl NetLoop {
Greeting::ok(
Some(Code::Capability(ctx.server_capabilities.to_vec())),
"Aerogramme",
- )
- .unwrap(),
)
- .await?;
+ .unwrap(),
+ )
+ .await?;
// Start a mailbox session in background
let (cmd_tx, mut cmd_rx) = mpsc::channel::<Request>(3);
@@ -164,11 +164,20 @@ impl NetLoop {
tokio::spawn(Self::session(ctx.clone(), cmd_rx, resp_tx));
// Return the object
- Ok(NetLoop { ctx, server, cmd_tx, resp_rx })
+ Ok(NetLoop {
+ ctx,
+ server,
+ cmd_tx,
+ resp_rx,
+ })
}
/// Coms with the background session
- async fn session(ctx: ClientContext, mut cmd_rx: Receiver<Request>, resp_tx: UnboundedSender<ResponseOrIdle>) -> () {
+ async fn session(
+ ctx: ClientContext,
+ mut cmd_rx: Receiver<Request>,
+ resp_tx: UnboundedSender<ResponseOrIdle>,
+ ) -> () {
let mut session = Instance::new(ctx.login_provider, ctx.server_capabilities);
loop {
let cmd = match cmd_rx.recv().await {
@@ -200,7 +209,6 @@ impl NetLoop {
Ok(())
}
-
async fn interactive_mode(&mut self) -> Result<LoopMode> {
tokio::select! {
// Managing imap_flow stuff
@@ -252,7 +260,7 @@ impl NetLoop {
tracing::error!("session task exited for {:?}, quitting", self.ctx.addr);
},
Some(_) => unreachable!(),
-
+
},
// When receiving a CTRL+C