core/either: Use io::Result type alias instead of renaming io::Error (#2687)

This commit is contained in:
Thomas Eizinger 2022-06-03 17:22:01 +02:00 committed by GitHub
parent c36a749478
commit bd9834aab4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,7 +28,7 @@ use futures::{
prelude::*, prelude::*,
}; };
use pin_project::pin_project; use pin_project::pin_project;
use std::{fmt, io::Error as IoError, pin::Pin, task::Context, task::Poll}; use std::{fmt, io, pin::Pin, task::Context, task::Poll};
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub enum EitherError<A, B> { pub enum EitherError<A, B> {
@ -80,7 +80,7 @@ where
self: Pin<&mut Self>, self: Pin<&mut Self>,
cx: &mut Context<'_>, cx: &mut Context<'_>,
buf: &mut [u8], buf: &mut [u8],
) -> Poll<Result<usize, IoError>> { ) -> Poll<io::Result<usize>> {
match self.project() { match self.project() {
EitherOutputProj::First(a) => AsyncRead::poll_read(a, cx, buf), EitherOutputProj::First(a) => AsyncRead::poll_read(a, cx, buf),
EitherOutputProj::Second(b) => AsyncRead::poll_read(b, cx, buf), EitherOutputProj::Second(b) => AsyncRead::poll_read(b, cx, buf),
@ -91,7 +91,7 @@ where
self: Pin<&mut Self>, self: Pin<&mut Self>,
cx: &mut Context<'_>, cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>], bufs: &mut [IoSliceMut<'_>],
) -> Poll<Result<usize, IoError>> { ) -> Poll<io::Result<usize>> {
match self.project() { match self.project() {
EitherOutputProj::First(a) => AsyncRead::poll_read_vectored(a, cx, bufs), EitherOutputProj::First(a) => AsyncRead::poll_read_vectored(a, cx, bufs),
EitherOutputProj::Second(b) => AsyncRead::poll_read_vectored(b, cx, bufs), EitherOutputProj::Second(b) => AsyncRead::poll_read_vectored(b, cx, bufs),
@ -108,7 +108,7 @@ where
self: Pin<&mut Self>, self: Pin<&mut Self>,
cx: &mut Context<'_>, cx: &mut Context<'_>,
buf: &[u8], buf: &[u8],
) -> Poll<Result<usize, IoError>> { ) -> Poll<io::Result<usize>> {
match self.project() { match self.project() {
EitherOutputProj::First(a) => AsyncWrite::poll_write(a, cx, buf), EitherOutputProj::First(a) => AsyncWrite::poll_write(a, cx, buf),
EitherOutputProj::Second(b) => AsyncWrite::poll_write(b, cx, buf), EitherOutputProj::Second(b) => AsyncWrite::poll_write(b, cx, buf),
@ -119,21 +119,21 @@ where
self: Pin<&mut Self>, self: Pin<&mut Self>,
cx: &mut Context<'_>, cx: &mut Context<'_>,
bufs: &[IoSlice<'_>], bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, IoError>> { ) -> Poll<io::Result<usize>> {
match self.project() { match self.project() {
EitherOutputProj::First(a) => AsyncWrite::poll_write_vectored(a, cx, bufs), EitherOutputProj::First(a) => AsyncWrite::poll_write_vectored(a, cx, bufs),
EitherOutputProj::Second(b) => AsyncWrite::poll_write_vectored(b, cx, bufs), EitherOutputProj::Second(b) => AsyncWrite::poll_write_vectored(b, cx, bufs),
} }
} }
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), IoError>> { fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
match self.project() { match self.project() {
EitherOutputProj::First(a) => AsyncWrite::poll_flush(a, cx), EitherOutputProj::First(a) => AsyncWrite::poll_flush(a, cx),
EitherOutputProj::Second(b) => AsyncWrite::poll_flush(b, cx), EitherOutputProj::Second(b) => AsyncWrite::poll_flush(b, cx),
} }
} }
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), IoError>> { fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
match self.project() { match self.project() {
EitherOutputProj::First(a) => AsyncWrite::poll_close(a, cx), EitherOutputProj::First(a) => AsyncWrite::poll_close(a, cx),
EitherOutputProj::Second(b) => AsyncWrite::poll_close(b, cx), EitherOutputProj::Second(b) => AsyncWrite::poll_close(b, cx),
@ -203,7 +203,7 @@ where
{ {
type Substream = EitherOutput<A::Substream, B::Substream>; type Substream = EitherOutput<A::Substream, B::Substream>;
type OutboundSubstream = EitherOutbound<A, B>; type OutboundSubstream = EitherOutbound<A, B>;
type Error = IoError; type Error = io::Error;
fn poll_event( fn poll_event(
&self, &self,