From 90b143e1c57c6561998176878b2cc586b2d89c80 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 29 Jun 2022 12:50:44 +0200 Subject: Refactor to allow mutability --- src/imap/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/imap/mod.rs') 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); + pub async fn new(config: ImapConfig, login: ArcLoginProvider) -> Result { //@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 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) -> 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 for Connection { type Response = Response; type Error = BalError; -- cgit v1.2.3