use super::{BidirectionalStream, SendStream};
#[derive(Debug)]
pub enum LocalStream {
Bidirectional(BidirectionalStream),
Send(SendStream),
}
impl LocalStream {
pub fn id(&self) -> u64 {
match self {
Self::Bidirectional(stream) => stream.id(),
Self::Send(stream) => stream.id(),
}
}
impl_connection_api!(|stream| match stream {
LocalStream::Bidirectional(stream) => stream.connection(),
LocalStream::Send(stream) => stream.connection(),
});
impl_receive_stream_api!(|stream, dispatch| match stream {
LocalStream::Bidirectional(stream) => dispatch!(stream),
LocalStream::Send(_stream) => dispatch!(),
});
impl_send_stream_api!(|stream, dispatch| match stream {
LocalStream::Bidirectional(stream) => dispatch!(stream),
LocalStream::Send(stream) => dispatch!(stream),
});
impl_splittable_stream_api!();
}
impl_receive_stream_trait!(LocalStream, |stream, dispatch| match stream {
LocalStream::Bidirectional(stream) => dispatch!(stream),
LocalStream::Send(_stream) => dispatch!(),
});
impl_send_stream_trait!(LocalStream, |stream, dispatch| match stream {
LocalStream::Bidirectional(stream) => dispatch!(stream),
LocalStream::Send(stream) => dispatch!(stream),
});
impl_splittable_stream_trait!(LocalStream, |stream| match stream {
LocalStream::Bidirectional(stream) => super::SplittableStream::split(stream),
LocalStream::Send(stream) => super::SplittableStream::split(stream),
});
impl From<SendStream> for LocalStream {
#[inline]
fn from(stream: SendStream) -> Self {
Self::Send(stream)
}
}
impl From<BidirectionalStream> for LocalStream {
#[inline]
fn from(stream: BidirectionalStream) -> Self {
Self::Bidirectional(stream)
}
}