#[cfg(not(feature = "no_send"))]
mod inner {
pub trait MaybeSend: Send {}
impl<T: Send + ?Sized> MaybeSend for T {}
pub trait MaybeSync: Sync {}
impl<T: Sync + ?Sized> MaybeSync for T {}
}
#[cfg(feature = "no_send")]
mod inner {
pub trait MaybeSend {}
impl<T: ?Sized> MaybeSend for T {}
pub trait MaybeSync {}
impl<T: ?Sized> MaybeSync for T {}
}
use std::{future::Future, pin::Pin};
use futures_util::Stream;
pub use inner::*;
#[doc(hidden)]
#[cfg(not(feature = "no_send"))]
pub type MaybeBoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
#[doc(hidden)]
#[cfg(feature = "no_send")]
pub type MaybeBoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a>>;
#[doc(hidden)]
#[cfg(not(feature = "no_send"))]
pub type MaybeBoxStream<'a, T> = Pin<Box<dyn Stream<Item = T> + Send + 'a>>;
#[doc(hidden)]
#[cfg(feature = "no_send")]
pub type MaybeBoxStream<'a, T> = Pin<Box<dyn Stream<Item = T> + 'a>>;
pub(crate) trait FutureMaybeSendExt: Future + Sized {
fn boxed_maybe_send<'a>(self) -> MaybeBoxFuture<'a, Self::Output>
where
Self: MaybeSend + 'a,
{
Box::pin(self)
}
}
impl<T: Future + Sized> FutureMaybeSendExt for T {}
#[allow(dead_code)]
pub(crate) trait StreamMaybeSendExt: Stream + Sized {
fn boxed_maybe_send<'a>(self) -> MaybeBoxStream<'a, Self::Item>
where
Self: MaybeSend + 'a,
{
Box::pin(self)
}
}
impl<T: Stream + Sized> StreamMaybeSendExt for T {}