Struct tor_chanmgr::ChanMgr
source · [−]pub struct ChanMgr<R: Runtime> { /* private fields */ }
Expand description
A Type that remembers a set of live channels, and launches new ones on request.
Use the ChanMgr::get_or_launch function to create a new channel, or get one if it exists.
Implementations
sourceimpl<R: Runtime> ChanMgr<R>
impl<R: Runtime> ChanMgr<R>
sourcepub fn new(runtime: R) -> Self
pub fn new(runtime: R) -> Self
Construct a new channel manager.
Usage note
For the manager to work properly, you will need to call ChanMgr::launch_background_tasks
.
sourcepub fn launch_background_tasks(
self: &Arc<Self>,
runtime: &R
) -> Result<Vec<TaskHandle>>
pub fn launch_background_tasks(
self: &Arc<Self>,
runtime: &R
) -> Result<Vec<TaskHandle>>
Launch the periodic daemon task required by the manager to function properly.
Returns a TaskHandle
that can be used to manage the daemon task.
sourcepub async fn get_or_launch<T: ChanTarget + ?Sized>(
&self,
target: &T
) -> Result<(Channel, ChanProvenance)>
pub async fn get_or_launch<T: ChanTarget + ?Sized>(
&self,
target: &T
) -> Result<(Channel, ChanProvenance)>
Try to get a suitable channel to the provided target
,
launching one if one does not exist.
If there is already a channel launch attempt in progress, this function will wait until that launch is complete, and succeed or fail depending on its outcome.
sourcepub fn bootstrap_events(&self) -> ConnStatusEvents
pub fn bootstrap_events(&self) -> ConnStatusEvents
Return a stream of ConnStatus
events to tell us about changes
in our ability to connect to the internet.
Note that this stream can be lossy: the caller will not necessarily observe every event on the stream
sourcepub fn expire_channels(&self) -> Duration
pub fn expire_channels(&self) -> Duration
Expire all channels that have been unused for too long.
Return the duration from now until next channel expires.
Auto Trait Implementations
impl<R> !RefUnwindSafe for ChanMgr<R>
impl<R> Send for ChanMgr<R>
impl<R> Sync for ChanMgr<R>
impl<R> Unpin for ChanMgr<R> where
R: Unpin,
impl<R> !UnwindSafe for ChanMgr<R>
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> 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