From 05b5efc8bf21a5e8422ae29e874969afd8ad9869 Mon Sep 17 00:00:00 2001 From: KokaKiwi Date: Fri, 13 May 2022 17:56:43 +0200 Subject: [PATCH] style: Use tower-provided type-alias when useful --- src/server/mod.rs | 4 ++-- src/server/pipeline.rs | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 1e0158b..8739bb4 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -20,7 +20,7 @@ pub enum Error { #[error("Error occured when accepting new connections")] Accept(#[source] A), #[error("Error occured on service creation")] - MakeService(#[source] Box), + MakeService(#[source] tower::BoxError), } #[derive(Debug, Default, Clone)] @@ -51,7 +51,7 @@ where I: Accept, I::Conn: AsyncRead + AsyncWrite + Unpin + Send + 'static, S: MakeServiceRef, - S::MakeError: Into> + std::fmt::Display, + S::MakeError: Into + std::fmt::Display, S::Error: std::fmt::Display, S::Future: Send + 'static, S::Service: Send + 'static, diff --git a/src/server/pipeline.rs b/src/server/pipeline.rs index f284348..477487c 100644 --- a/src/server/pipeline.rs +++ b/src/server/pipeline.rs @@ -8,7 +8,8 @@ use futures::stream::Stream; use crate::proto::{Request, Response}; -type Error = Box; +type Error = tower::BoxError; +type Result = std::result::Result; #[pin_project::pin_project] pub struct Connection { @@ -32,7 +33,7 @@ impl Stream for Connection where C: AsyncRead + Unpin, { - type Item = Result; + type Item = Result; fn poll_next(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll> { use imap_codec::parse::command::command as parse_command; @@ -75,7 +76,7 @@ impl Connection where C: AsyncWrite, { - fn poll_flush_buffer(self: Pin<&mut Self>, cx: &mut task::Context) -> Poll> { + fn poll_flush_buffer(self: Pin<&mut Self>, cx: &mut task::Context) -> Poll> { use bytes::Buf; let mut this = self.project(); @@ -89,7 +90,7 @@ where Poll::Ready(Ok(())) } - pub(crate) fn send(&mut self, item: Response) -> Result<(), Error> { + pub(crate) fn send(&mut self, item: Response) -> Result<()> { use bytes::BufMut; use imap_codec::codec::Encode;