1use super::{BidirectionalStream, SendStream};
5
6#[derive(Debug)]
8pub enum LocalStream {
9 Bidirectional(BidirectionalStream),
10 Send(SendStream),
11}
12
13impl LocalStream {
14 pub fn id(&self) -> u64 {
35 match self {
36 Self::Bidirectional(stream) => stream.id(),
37 Self::Send(stream) => stream.id(),
38 }
39 }
40
41 impl_connection_api!(|stream| match stream {
42 LocalStream::Bidirectional(stream) => stream.connection(),
43 LocalStream::Send(stream) => stream.connection(),
44 });
45
46 impl_receive_stream_api!(|stream, dispatch| match stream {
47 LocalStream::Bidirectional(stream) => dispatch!(stream),
48 LocalStream::Send(_stream) => dispatch!(),
49 });
50
51 impl_send_stream_api!(|stream, dispatch| match stream {
52 LocalStream::Bidirectional(stream) => dispatch!(stream),
53 LocalStream::Send(stream) => dispatch!(stream),
54 });
55
56 impl_splittable_stream_api!();
57}
58
59impl_receive_stream_trait!(LocalStream, |stream, dispatch| match stream {
60 LocalStream::Bidirectional(stream) => dispatch!(stream),
61 LocalStream::Send(_stream) => dispatch!(),
62});
63impl_send_stream_trait!(LocalStream, |stream, dispatch| match stream {
64 LocalStream::Bidirectional(stream) => dispatch!(stream),
65 LocalStream::Send(stream) => dispatch!(stream),
66});
67impl_splittable_stream_trait!(LocalStream, |stream| match stream {
68 LocalStream::Bidirectional(stream) => super::SplittableStream::split(stream),
69 LocalStream::Send(stream) => super::SplittableStream::split(stream),
70});
71
72impl From<SendStream> for LocalStream {
73 #[inline]
74 fn from(stream: SendStream) -> Self {
75 Self::Send(stream)
76 }
77}
78
79impl From<BidirectionalStream> for LocalStream {
80 #[inline]
81 fn from(stream: BidirectionalStream) -> Self {
82 Self::Bidirectional(stream)
83 }
84}