Loading crates/tor-proto/src/client/stream/data.rs +28 −16 Original line number Diff line number Diff line Loading @@ -140,8 +140,10 @@ pub struct DataStream { r: DataReader, /// A control object that can be used to monitor and control this stream /// without needing to own it. /// /// Set to `None` if this is not a client stream. #[cfg(feature = "stream-ctrl")] ctrl: Arc<ClientDataStreamCtrl>, ctrl: Option<Arc<ClientDataStreamCtrl>>, } assert_impl_all! { DataStream: Send, Sync } Loading Loading @@ -205,8 +207,10 @@ struct DataWriterInner { /// A control object that can be used to monitor and control this stream /// without needing to own it. /// /// Set to `None` if this is not a client stream. #[cfg(feature = "stream-ctrl")] ctrl: Arc<ClientDataStreamCtrl>, ctrl: Option<Arc<ClientDataStreamCtrl>>, } /// The write half of a [`DataStream`], implementing [`futures::io::AsyncWrite`]. Loading Loading @@ -292,9 +296,11 @@ impl DataWriter { /// Return a [`ClientDataStreamCtrl`] object that can be used to monitor and /// interact with this stream without holding the stream itself. /// /// Returns `None` if this is not a client stream. #[cfg(feature = "stream-ctrl")] pub fn client_stream_ctrl(&self) -> Option<&Arc<ClientDataStreamCtrl>> { Some(self.writer.inner().client_stream_ctrl()) self.writer.inner().client_stream_ctrl() } } Loading Loading @@ -362,9 +368,11 @@ impl DataReader { /// Return a [`ClientDataStreamCtrl`] object that can be used to monitor and /// interact with this stream without holding the stream itself. /// /// Returns `None` if this is not a client stream. #[cfg(feature = "stream-ctrl")] pub fn client_stream_ctrl(&self) -> Option<&Arc<ClientDataStreamCtrl>> { Some(self.reader.inner().client_stream_ctrl()) self.reader.inner().client_stream_ctrl() } } Loading Loading @@ -419,8 +427,10 @@ pub(crate) struct DataReaderInner { /// A control object that can be used to monitor and control this stream /// without needing to own it. /// /// Set to `None` if this is not a client stream. #[cfg(feature = "stream-ctrl")] ctrl: Arc<ClientDataStreamCtrl>, ctrl: Option<Arc<ClientDataStreamCtrl>>, } impl BufferIsEmpty for DataReaderInner { Loading Loading @@ -600,16 +610,18 @@ impl DataStream { #[cfg(feature = "stream-ctrl")] let ctrl = { let tunnel = match target.tunnel() { crate::stream::Tunnel::Client(t) => Arc::downgrade(t), crate::stream::Tunnel::Client(t) => Some(Arc::downgrade(t)), #[cfg(feature = "relay")] crate::stream::Tunnel::Relay(_) => panic!("created a relay tunnel in the client?!"), crate::stream::Tunnel::Relay(_) => None, }; tunnel.map(|tunnel| { Arc::new(ClientDataStreamCtrl { tunnel, status: status.clone(), _memquota: memquota.clone(), }) }) }; let r = DataReaderInner { state: Some(DataReaderState::Open(DataReaderImpl { Loading Loading @@ -691,7 +703,7 @@ impl DataStream { /// interact with this stream without holding the stream itself. #[cfg(feature = "stream-ctrl")] pub fn client_stream_ctrl(&self) -> Option<&Arc<ClientDataStreamCtrl>> { Some(&self.ctrl) self.ctrl.as_ref() } } Loading Loading @@ -803,8 +815,8 @@ struct DataWriterImpl { impl DataWriterInner { /// See [`DataWriter::client_stream_ctrl`]. #[cfg(feature = "stream-ctrl")] fn client_stream_ctrl(&self) -> &Arc<ClientDataStreamCtrl> { &self.ctrl fn client_stream_ctrl(&self) -> Option<&Arc<ClientDataStreamCtrl>> { self.ctrl.as_ref() } /// Helper for poll_flush() and poll_close(): Performs a flush, then Loading Loading @@ -991,8 +1003,8 @@ impl DataReaderInner { /// Return a [`ClientDataStreamCtrl`] object that can be used to monitor and /// interact with this stream without holding the stream itself. #[cfg(feature = "stream-ctrl")] pub(crate) fn client_stream_ctrl(&self) -> &Arc<ClientDataStreamCtrl> { &self.ctrl pub(crate) fn client_stream_ctrl(&self) -> Option<&Arc<ClientDataStreamCtrl>> { self.ctrl.as_ref() } } Loading crates/tor-proto/src/relay/reactor.rs +0 −1 Original line number Diff line number Diff line Loading @@ -786,7 +786,6 @@ pub(crate) mod test { #[traced_test] #[test] #[ignore] // TODO(relay): Sad trombone, this is not yet supported fn data_stream() { tor_rtmock::MockRuntime::test_with_various(|rt| async move { const TO_SEND: &[u8] = b"The bells were musical in the silvery sun"; Loading Loading
crates/tor-proto/src/client/stream/data.rs +28 −16 Original line number Diff line number Diff line Loading @@ -140,8 +140,10 @@ pub struct DataStream { r: DataReader, /// A control object that can be used to monitor and control this stream /// without needing to own it. /// /// Set to `None` if this is not a client stream. #[cfg(feature = "stream-ctrl")] ctrl: Arc<ClientDataStreamCtrl>, ctrl: Option<Arc<ClientDataStreamCtrl>>, } assert_impl_all! { DataStream: Send, Sync } Loading Loading @@ -205,8 +207,10 @@ struct DataWriterInner { /// A control object that can be used to monitor and control this stream /// without needing to own it. /// /// Set to `None` if this is not a client stream. #[cfg(feature = "stream-ctrl")] ctrl: Arc<ClientDataStreamCtrl>, ctrl: Option<Arc<ClientDataStreamCtrl>>, } /// The write half of a [`DataStream`], implementing [`futures::io::AsyncWrite`]. Loading Loading @@ -292,9 +296,11 @@ impl DataWriter { /// Return a [`ClientDataStreamCtrl`] object that can be used to monitor and /// interact with this stream without holding the stream itself. /// /// Returns `None` if this is not a client stream. #[cfg(feature = "stream-ctrl")] pub fn client_stream_ctrl(&self) -> Option<&Arc<ClientDataStreamCtrl>> { Some(self.writer.inner().client_stream_ctrl()) self.writer.inner().client_stream_ctrl() } } Loading Loading @@ -362,9 +368,11 @@ impl DataReader { /// Return a [`ClientDataStreamCtrl`] object that can be used to monitor and /// interact with this stream without holding the stream itself. /// /// Returns `None` if this is not a client stream. #[cfg(feature = "stream-ctrl")] pub fn client_stream_ctrl(&self) -> Option<&Arc<ClientDataStreamCtrl>> { Some(self.reader.inner().client_stream_ctrl()) self.reader.inner().client_stream_ctrl() } } Loading Loading @@ -419,8 +427,10 @@ pub(crate) struct DataReaderInner { /// A control object that can be used to monitor and control this stream /// without needing to own it. /// /// Set to `None` if this is not a client stream. #[cfg(feature = "stream-ctrl")] ctrl: Arc<ClientDataStreamCtrl>, ctrl: Option<Arc<ClientDataStreamCtrl>>, } impl BufferIsEmpty for DataReaderInner { Loading Loading @@ -600,16 +610,18 @@ impl DataStream { #[cfg(feature = "stream-ctrl")] let ctrl = { let tunnel = match target.tunnel() { crate::stream::Tunnel::Client(t) => Arc::downgrade(t), crate::stream::Tunnel::Client(t) => Some(Arc::downgrade(t)), #[cfg(feature = "relay")] crate::stream::Tunnel::Relay(_) => panic!("created a relay tunnel in the client?!"), crate::stream::Tunnel::Relay(_) => None, }; tunnel.map(|tunnel| { Arc::new(ClientDataStreamCtrl { tunnel, status: status.clone(), _memquota: memquota.clone(), }) }) }; let r = DataReaderInner { state: Some(DataReaderState::Open(DataReaderImpl { Loading Loading @@ -691,7 +703,7 @@ impl DataStream { /// interact with this stream without holding the stream itself. #[cfg(feature = "stream-ctrl")] pub fn client_stream_ctrl(&self) -> Option<&Arc<ClientDataStreamCtrl>> { Some(&self.ctrl) self.ctrl.as_ref() } } Loading Loading @@ -803,8 +815,8 @@ struct DataWriterImpl { impl DataWriterInner { /// See [`DataWriter::client_stream_ctrl`]. #[cfg(feature = "stream-ctrl")] fn client_stream_ctrl(&self) -> &Arc<ClientDataStreamCtrl> { &self.ctrl fn client_stream_ctrl(&self) -> Option<&Arc<ClientDataStreamCtrl>> { self.ctrl.as_ref() } /// Helper for poll_flush() and poll_close(): Performs a flush, then Loading Loading @@ -991,8 +1003,8 @@ impl DataReaderInner { /// Return a [`ClientDataStreamCtrl`] object that can be used to monitor and /// interact with this stream without holding the stream itself. #[cfg(feature = "stream-ctrl")] pub(crate) fn client_stream_ctrl(&self) -> &Arc<ClientDataStreamCtrl> { &self.ctrl pub(crate) fn client_stream_ctrl(&self) -> Option<&Arc<ClientDataStreamCtrl>> { self.ctrl.as_ref() } } Loading
crates/tor-proto/src/relay/reactor.rs +0 −1 Original line number Diff line number Diff line Loading @@ -786,7 +786,6 @@ pub(crate) mod test { #[traced_test] #[test] #[ignore] // TODO(relay): Sad trombone, this is not yet supported fn data_stream() { tor_rtmock::MockRuntime::test_with_various(|rt| async move { const TO_SEND: &[u8] = b"The bells were musical in the silvery sun"; Loading