#[cfg(feature = "tokio")]
use crate::os::windows::{tokio_flusher::TokioFlusher, OptArcIRC};
use {
super::super::*,
crate::os::windows::{MaybeArc, OptArc},
std::sync::Arc,
};
pub mod pipe_mode {
use super::*;
mod seal {
use super::*;
pub trait PipeModeTag: Copy + std::fmt::Debug + Eq + Send + Sync + Unpin {
const MODE: Option<PipeMode>;
type OptArc<T>: OptArc<Value = T>
where
T: Send + Sync;
#[cfg(feature = "tokio")]
type TokioFlusher: std::fmt::Debug + Default;
}
#[cfg(feature = "tokio")]
pub(crate) trait PmtOptArcIRC: PipeModeTag {
fn cast_oai(
oa: &Self::OptArc<tokio::RawPipeStream>,
) -> &(impl OptArcIRC<Value = tokio::RawPipeStream> + 'static);
}
#[cfg(feature = "tokio")]
impl<T: PipeModeTag> PmtOptArcIRC for T
where
T::OptArc<tokio::RawPipeStream>: OptArcIRC + 'static,
{
#[cfg(feature = "tokio")]
fn cast_oai(
oa: &Self::OptArc<tokio::RawPipeStream>,
) -> &(impl OptArcIRC<Value = tokio::RawPipeStream> + 'static) {
oa
}
}
#[cfg(feature = "tokio")]
#[allow(private_bounds)]
pub trait NotNone: PipeModeTag<TokioFlusher = TokioFlusher> + PmtOptArcIRC {}
#[cfg(not(feature = "tokio"))]
pub trait NotNone: PipeModeTag {}
}
pub(crate) use seal::*;
macro_rules! present_tag {
($(#[$attr:meta])* $tag:ident is $mode:expr ; no_tokio_flusher) => {
tag_enum!($( #[$attr] )* $tag);
impl PipeModeTag for $tag {
const MODE: Option<PipeMode> = $mode;
type OptArc<T> = MaybeArc<T> where T: Send + Sync;
#[cfg(feature = "tokio")]
type TokioFlusher = ();
}
};
($(#[$attr:meta])* $tag:ident is $mode:expr) => {
tag_enum!($( #[$attr] )* $tag);
impl PipeModeTag for $tag {
const MODE: Option<PipeMode> = $mode;
type OptArc<T> = Arc<T> where T: Send + Sync;
#[cfg(feature = "tokio")]
type TokioFlusher = TokioFlusher;
}
};
($($(#[$attr:meta])* $tag:ident is $mode:expr $(; $yayornay:ident)?),+ $(,)?) => {
$(present_tag!($( #[$attr] )* $tag is $mode $(; $yayornay)?);)+
};
}
present_tag! {
None is None ; no_tokio_flusher,
Bytes is Some(PipeMode::Bytes),
Messages is Some(PipeMode::Messages),
}
impl NotNone for Bytes {}
impl NotNone for Messages {}
}
pub(crate) use pipe_mode::{NotNone as PmtNotNone, PipeModeTag};