aboutsummaryrefslogtreecommitdiff
path: root/src/imap/mod.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-29 12:50:44 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-29 12:50:44 +0200
commit90b143e1c57c6561998176878b2cc586b2d89c80 (patch)
treea9f07995d9d29e9f884756cad5732bfb2cbeb3fc /src/imap/mod.rs
parent9979671b001ccb25917da7091d13ad3fc1096330 (diff)
downloadaerogramme-90b143e1c57c6561998176878b2cc586b2d89c80.tar.gz
aerogramme-90b143e1c57c6561998176878b2cc586b2d89c80.zip
Refactor to allow mutability
Diffstat (limited to 'src/imap/mod.rs')
-rw-r--r--src/imap/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/imap/mod.rs b/src/imap/mod.rs
index 63f0220..b725859 100644
--- a/src/imap/mod.rs
+++ b/src/imap/mod.rs
@@ -20,6 +20,7 @@ use crate::login::ArcLoginProvider;
/// Server is a thin wrapper to register our Services in BàL
pub struct Server(ImapServer<AddrIncoming, Instance>);
+
pub async fn new(config: ImapConfig, login: ArcLoginProvider) -> Result<Server> {
//@FIXME add a configuration parameter
let incoming = AddrIncoming::new(config.bind_addr).await?;
@@ -28,6 +29,7 @@ pub async fn new(config: ImapConfig, login: ArcLoginProvider) -> Result<Server>
let imap = ImapServer::new(incoming).serve(Instance::new(login.clone()));
Ok(Server(imap))
}
+
impl Server {
pub async fn run(self, mut must_exit: watch::Receiver<bool>) -> Result<()> {
tracing::info!("IMAP started!");
@@ -47,11 +49,13 @@ impl Server {
struct Instance {
login_provider: ArcLoginProvider,
}
+
impl Instance {
pub fn new(login_provider: ArcLoginProvider) -> Self {
Self { login_provider }
}
}
+
impl<'a> Service<&'a AddrStream> for Instance {
type Response = Connection;
type Error = anyhow::Error;
@@ -75,6 +79,7 @@ impl<'a> Service<&'a AddrStream> for Instance {
struct Connection {
session: session::Manager,
}
+
impl Connection {
pub fn new(login_provider: ArcLoginProvider) -> Self {
Self {
@@ -82,6 +87,7 @@ impl Connection {
}
}
}
+
impl Service<Request> for Connection {
type Response = Response;
type Error = BalError;