tor_proto/client/stream/ctrl.rs
1//! Common types for `StreamCtrl` traits and objects, used to provide a
2//! shareable handle for controlling a string.
3
4use std::sync::Arc;
5
6use crate::client::ClientTunnel;
7
8/// An object that lets the owner "control" a client stream.
9///
10/// In some cases, this may be the stream itself; in others, it will be a handle
11/// to the shared parts of the stream. (For data streams, it's not convenient to
12/// make the actual `AsyncRead` and `AsyncWrite` types shared, since all the methods
13/// on those traits take `&mut self`.)
14///
15/// This applies to client streams only.
16pub trait ClientStreamCtrl {
17 /// Return the circuit that this stream is attached to, if that circuit
18 /// object is still present.
19 ///
20 /// (If the circuit object itself is not present, the stream is necessarily
21 /// closed.)
22 fn tunnel(&self) -> Option<Arc<ClientTunnel>>;
23}