style: Use tower-provided type-alias when useful

This commit is contained in:
Jill 2022-05-13 17:56:43 +02:00
parent 54aa382f8b
commit 05b5efc8bf
Signed by untrusted user: KokaKiwi
GPG Key ID: 09A5A2688F13FAC1
2 changed files with 7 additions and 6 deletions

View File

@ -20,7 +20,7 @@ pub enum Error<A> {
#[error("Error occured when accepting new connections")]
Accept(#[source] A),
#[error("Error occured on service creation")]
MakeService(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
MakeService(#[source] tower::BoxError),
}
#[derive(Debug, Default, Clone)]
@ -51,7 +51,7 @@ where
I: Accept,
I::Conn: AsyncRead + AsyncWrite + Unpin + Send + 'static,
S: MakeServiceRef<I::Conn, Request, Response = Response>,
S::MakeError: Into<Box<dyn std::error::Error + Send + Sync + 'static>> + std::fmt::Display,
S::MakeError: Into<tower::BoxError> + std::fmt::Display,
S::Error: std::fmt::Display,
S::Future: Send + 'static,
S::Service: Send + 'static,

View File

@ -8,7 +8,8 @@ use futures::stream::Stream;
use crate::proto::{Request, Response};
type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
type Error = tower::BoxError;
type Result<T, E = Error> = std::result::Result<T, E>;
#[pin_project::pin_project]
pub struct Connection<C> {
@ -32,7 +33,7 @@ impl<C> Stream for Connection<C>
where
C: AsyncRead + Unpin,
{
type Item = Result<Request, Error>;
type Item = Result<Request>;
fn poll_next(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Option<Self::Item>> {
use imap_codec::parse::command::command as parse_command;
@ -75,7 +76,7 @@ impl<C> Connection<C>
where
C: AsyncWrite,
{
fn poll_flush_buffer(self: Pin<&mut Self>, cx: &mut task::Context) -> Poll<Result<(), Error>> {
fn poll_flush_buffer(self: Pin<&mut Self>, cx: &mut task::Context) -> Poll<Result<()>> {
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;