pub struct Channel { /* private fields */ }
Expand description
An open client channel, ready to send and receive Tor cells.
A channel is a direct connection to a Tor relay, implemented using TLS.
This struct is a frontend that can be used to send cells (using the Sink<ChanCell>
impl and otherwise control the channel. The main state is in the Reactor object.
Channel
is cheap to clone.
(Users need a mutable reference because of the types in Sink
, and ultimately because
cell_tx: mpsc::Sender
doesn’t work without mut.
Implementations
sourceimpl Channel
impl Channel
sourcepub fn peer_ed25519_id(&self) -> &Ed25519Identity
pub fn peer_ed25519_id(&self) -> &Ed25519Identity
Return the Ed25519 identity for the peer of this channel.
sourcepub fn peer_rsa_id(&self) -> &RsaIdentity
pub fn peer_rsa_id(&self) -> &RsaIdentity
Return the (legacy) RSA identity for the peer of this channel.
sourcepub fn target(&self) -> &OwnedChanTarget
pub fn target(&self) -> &OwnedChanTarget
Return an OwnedChanTarget representing the actual handshake used to create this channel.
sourcepub fn age(&self) -> Duration
pub fn age(&self) -> Duration
Return the amount of time that has passed since this channel became open.
sourcepub fn clock_skew(&self) -> ClockSkew
pub fn clock_skew(&self) -> ClockSkew
Return a ClockSkew declaring how much clock skew the other side of this channel claimed that we had when we negotiated the connection.
sourcepub fn check_match<T: ChanTarget + ?Sized>(&self, target: &T) -> Result<()>
pub fn check_match<T: ChanTarget + ?Sized>(&self, target: &T) -> Result<()>
Return an error if this channel is somehow mismatched with the given target.
sourcepub fn is_closing(&self) -> bool
pub fn is_closing(&self) -> bool
Return true if this channel is closed and therefore unusable.
sourcepub fn duration_unused(&self) -> Option<Duration>
pub fn duration_unused(&self) -> Option<Duration>
If the channel is not in use, return the amount of time it has had with no circuits.
Return None
if the channel is currently in use.
sourcepub fn poll_ready(&mut self, cx: &mut Context<'_>) -> Result<bool>
pub fn poll_ready(&mut self, cx: &mut Context<'_>) -> Result<bool>
Like futures::Sink::poll_ready
.
sourcepub async fn send_cell(&mut self, cell: ChanCell) -> Result<()>
pub async fn send_cell(&mut self, cell: ChanCell) -> Result<()>
Transmit a single cell on a channel.
sourcepub async fn new_circ(&self) -> Result<(PendingClientCirc, Reactor)>
pub async fn new_circ(&self) -> Result<(PendingClientCirc, Reactor)>
Return a newly allocated PendingClientCirc object with a corresponding circuit reactor. A circuit ID is allocated, but no messages are sent, and no cryptography is done.
To use the results of this method, call Reactor::run() in a new task, then use the methods of crate::circuit::PendingClientCirc to build the circuit.
sourcepub fn terminate(&self)
pub fn terminate(&self)
Shut down this channel immediately, along with all circuits that are using it.
Note that other references to this channel may exist. If they do, they will stop working after you call this function.
It’s not necessary to call this method if you’re just done with a channel: the channel should close on its own once nothing is using it any more.
sourcepub fn close_circuit(&self, circid: CircId) -> Result<()>
pub fn close_circuit(&self, circid: CircId) -> Result<()>
Tell the reactor that the circuit with the given ID has gone away.
Trait Implementations
sourceimpl Sink<ChanCell> for Channel
impl Sink<ChanCell> for Channel
sourcefn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Attempts to prepare the Sink
to receive a value. Read more
sourcefn start_send(self: Pin<&mut Self>, cell: ChanCell) -> Result<()>
fn start_send(self: Pin<&mut Self>, cell: ChanCell) -> Result<()>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready
which returned Poll::Ready(Ok(()))
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Channel
impl Send for Channel
impl Sync for Channel
impl Unpin for Channel
impl !UnwindSafe for Channel
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Item> SinkExt<Item> for T where
T: Sink<Item> + ?Sized,
impl<T, Item> SinkExt<Item> for T where
T: Sink<Item> + ?Sized,
sourcefn with<U, Fut, F, E>(self, f: F) -> With<Self, Item, U, Fut, F> where
F: FnMut(U) -> Fut,
Fut: Future<Output = Result<Item, E>>,
E: From<Self::Error>,
fn with<U, Fut, F, E>(self, f: F) -> With<Self, Item, U, Fut, F> where
F: FnMut(U) -> Fut,
Fut: Future<Output = Result<Item, E>>,
E: From<Self::Error>,
Composes a function in front of the sink. Read more
sourcefn with_flat_map<U, St, F>(self, f: F) -> WithFlatMap<Self, Item, U, St, F> where
F: FnMut(U) -> St,
St: Stream<Item = Result<Item, Self::Error>>,
fn with_flat_map<U, St, F>(self, f: F) -> WithFlatMap<Self, Item, U, St, F> where
F: FnMut(U) -> St,
St: Stream<Item = Result<Item, Self::Error>>,
Composes a function in front of the sink. Read more
sourcefn sink_map_err<E, F>(self, f: F) -> SinkMapErr<Self, F> where
F: FnOnce(Self::Error) -> E,
fn sink_map_err<E, F>(self, f: F) -> SinkMapErr<Self, F> where
F: FnOnce(Self::Error) -> E,
Transforms the error returned by the sink.
sourcefn sink_err_into<E>(self) -> SinkErrInto<Self, Item, E> where
Self::Error: Into<E>,
fn sink_err_into<E>(self) -> SinkErrInto<Self, Item, E> where
Self::Error: Into<E>,
Map this sink’s error to a different error type using the Into
trait. Read more
sourcefn buffer(self, capacity: usize) -> Buffer<Self, Item>
fn buffer(self, capacity: usize) -> Buffer<Self, Item>
Adds a fixed-size buffer to the current sink. Read more
sourcefn fanout<Si>(self, other: Si) -> Fanout<Self, Si> where
Item: Clone,
Si: Sink<Item, Error = Self::Error>,
fn fanout<Si>(self, other: Si) -> Fanout<Self, Si> where
Item: Clone,
Si: Sink<Item, Error = Self::Error>,
Fanout items to multiple sinks. Read more
sourcefn flush(&mut self) -> Flush<'_, Self, Item> where
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self, Item> where
Self: Unpin,
Flush the sink, processing all pending items. Read more
sourcefn send(&mut self, item: Item) -> Send<'_, Self, Item> where
Self: Unpin,
fn send(&mut self, item: Item) -> Send<'_, Self, Item> where
Self: Unpin,
A future that completes after the given item has been fully processed into the sink, including flushing. Read more
sourcefn feed(&mut self, item: Item) -> Feed<'_, Self, Item> where
Self: Unpin,
fn feed(&mut self, item: Item) -> Feed<'_, Self, Item> where
Self: Unpin,
A future that completes after the given item has been received by the sink. Read more
sourcefn send_all<St>(&'a mut self, stream: &'a mut St) -> SendAll<'a, Self, St> where
St: TryStream<Ok = Item, Error = Self::Error> + Stream + Unpin + ?Sized,
Self: Unpin,
fn send_all<St>(&'a mut self, stream: &'a mut St) -> SendAll<'a, Self, St> where
St: TryStream<Ok = Item, Error = Self::Error> + Stream + Unpin + ?Sized,
Self: Unpin,
A future that completes after the given stream has been fully processed into the sink, including flushing. Read more
sourcefn left_sink<Si2>(self) -> Either<Self, Si2> where
Si2: Sink<Item, Error = Self::Error>,
fn left_sink<Si2>(self) -> Either<Self, Si2> where
Si2: Sink<Item, Error = Self::Error>,
Wrap this sink in an Either
sink, making it the left-hand variant
of that Either
. Read more
sourcefn right_sink<Si1>(self) -> Either<Si1, Self> where
Si1: Sink<Item, Error = Self::Error>,
fn right_sink<Si1>(self) -> Either<Si1, Self> where
Si1: Sink<Item, Error = Self::Error>,
Wrap this stream in an Either
stream, making it the right-hand variant
of that Either
. Read more
sourcefn poll_ready_unpin(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>> where
Self: Unpin,
fn poll_ready_unpin(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>> where
Self: Unpin,
A convenience method for calling Sink::poll_ready
on Unpin
sink types. Read more
sourcefn start_send_unpin(&mut self, item: Item) -> Result<(), Self::Error> where
Self: Unpin,
fn start_send_unpin(&mut self, item: Item) -> Result<(), Self::Error> where
Self: Unpin,
A convenience method for calling Sink::start_send
on Unpin
sink types. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more