Ret BinstallError in <AutoAbortJoinHandle as Future>::poll

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-08-04 18:37:52 +10:00
parent 36066fd4df
commit a13180f79a
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -5,7 +5,9 @@ use std::{
task::{Context, Poll}, task::{Context, Poll},
}; };
use tokio::task::{JoinError, JoinHandle}; use tokio::task::JoinHandle;
use super::BinstallError;
#[derive(Debug)] #[derive(Debug)]
pub struct AutoAbortJoinHandle<T>(JoinHandle<T>); pub struct AutoAbortJoinHandle<T>(JoinHandle<T>);
@ -49,9 +51,11 @@ impl<T> DerefMut for AutoAbortJoinHandle<T> {
} }
impl<T> Future for AutoAbortJoinHandle<T> { impl<T> Future for AutoAbortJoinHandle<T> {
type Output = Result<T, JoinError>; type Output = Result<T, BinstallError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
Pin::new(&mut Pin::into_inner(self).0).poll(cx) Pin::new(&mut Pin::into_inner(self).0)
.poll(cx)
.map(|res| res.map_err(BinstallError::TaskJoinError))
} }
} }