aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-06-02 17:12:58 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-06-02 17:12:58 +0200
commit3370760891d05ded9ec5fabac634f5c08ef6ba46 (patch)
tree890e88891936f5e9429397d815a7866cb88f3a60 /src
parent81e647e8818590a5589803cd810ff3018698e786 (diff)
downloadaerogramme-3370760891d05ded9ec5fabac634f5c08ef6ba46.tar.gz
aerogramme-3370760891d05ded9ec5fabac634f5c08ef6ba46.zip
Working services
Diffstat (limited to 'src')
-rw-r--r--src/server.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/server.rs b/src/server.rs
index e9b05d8..81ffcd5 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -46,6 +46,22 @@ impl Service<Request> for Echo {
}
}
+struct Charlie;
+impl<'a> Service<&'a AddrStream> for Charlie {
+ type Response = Echo;
+ type Error = anyhow::Error;
+ type Future = Pin<Box<dyn futures::Future<Output = Result<Self::Response>> + Send>>;
+
+ fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
+ Poll::Ready(Ok(()))
+ }
+
+ fn call(&mut self, addr: &'a AddrStream) -> Self::Future {
+ println!("{}, {}", addr.remote_addr, addr.local_addr);
+ let fut = futures::future::ok(Echo);
+ Box::pin(fut)
+ }
+}
impl Server {
pub fn new(config: Config) -> Result<Arc<Self>> {
@@ -73,18 +89,18 @@ impl Server {
let incoming = AddrIncoming::new("127.0.0.1:4567").await?;
- let make_service = tower::service_fn(|addr: &AddrStream| {
+ /*let make_service = tower::service_fn(|addr: &AddrStream| {
tracing::debug!(remote_addr = %addr.remote_addr, local_addr = %addr.local_addr, "accept");
//let service = tower::ServiceBuilder::new().service_fn(handle_req);
//let service = tower::service_fn(handle_req);
let service = Echo;
futures::future::ok::<_, std::convert::Infallible>(service)
//service
- });
+ });*/
//println!("{:?}", make_service);
- let server = ImapServer::new(incoming).serve(make_service);
+ let server = ImapServer::new(incoming).serve(Charlie);
let _ = server.await?;
/*let creds = self.login_provider.login("quentin", "poupou").await?;