pub struct WithDispatch<T> { /* private fields */ }
std
only.Expand description
A future, stream, sink, or executor that has been instrumented with a
tracing
subscriber.
Implementations§
Source§impl WithDispatch<Runtime>
impl WithDispatch<Runtime>
Sourcepub fn spawn<F>(&mut self, future: F) -> &mut Self
pub fn spawn<F>(&mut self, future: F) -> &mut Self
Spawn a future onto the Tokio runtime, in the context of this
WithDispatch
’s trace dispatcher.
This spawns the given future onto the runtime’s executor, usually a thread pool. The thread pool is then responsible for polling the future until it completes.
This method simply wraps a call to tokio::runtime::Runtime::spawn
,
instrumenting the spawned future beforehand.
Sourcepub fn block_on<F, R, E>(&mut self, future: F) -> Result<R, E>
pub fn block_on<F, R, E>(&mut self, future: F) -> Result<R, E>
Run a future to completion on the Tokio runtime, in the context of this
WithDispatch
’s trace dispatcher.
This runs the given future on the runtime, blocking until it is complete, and yielding its resolved result. Any tasks or timers which the future spawns internally will be executed on the runtime.
This method should not be called from an asynchronous context.
This method simply wraps a call to tokio::runtime::Runtime::block_on
,
instrumenting the spawned future beforehand.
§Panics
This function panics if the executor is at capacity, if the provided future panics, or if called within an asynchronous execution context.
Sourcepub fn executor(&self) -> WithDispatch<TaskExecutor> ⓘ
pub fn executor(&self) -> WithDispatch<TaskExecutor> ⓘ
Return a handle to the runtime’s executor, in the context of this
WithDispatch
’s trace dispatcher.
The returned handle can be used to spawn tasks that run on this runtime.
The instrumented handle functions identically to a
tokio::runtime::TaskExecutor
, but instruments the spawned
futures prior to spawning them.
Source§impl WithDispatch<Runtime>
impl WithDispatch<Runtime>
Sourcepub fn spawn<F>(&mut self, future: F) -> &mut Self
pub fn spawn<F>(&mut self, future: F) -> &mut Self
Spawn a future onto the single-threaded Tokio runtime, in the context
of this WithDispatch
’s trace dispatcher.
This method simply wraps a call to current_thread::Runtime::spawn
,
instrumenting the spawned future beforehand.
Sourcepub fn block_on<F, R, E>(&mut self, future: F) -> Result<R, E>where
F: 'static + Future<Item = R, Error = E>,
R: 'static,
E: 'static,
pub fn block_on<F, R, E>(&mut self, future: F) -> Result<R, E>where
F: 'static + Future<Item = R, Error = E>,
R: 'static,
E: 'static,
Runs the provided future in the context of this WithDispatch
’s trace
dispatcher, blocking the current thread until the future completes.
This function can be used to synchronously block the current thread
until the provided future
has resolved either successfully or with an
error. The result of the future is then returned from this function
call.
Note that this function will also execute any spawned futures on the
current thread, but will not block until these other spawned futures
have completed. Once the function returns, any uncompleted futures
remain pending in the Runtime
instance. These futures will not run
until block_on
or run
is called again.
The caller is responsible for ensuring that other spawned futures
complete execution by calling block_on
or run
.
This method simply wraps a call to current_thread::Runtime::block_on
,
instrumenting the spawned future beforehand.
§Panics
This function panics if the executor is at capacity, if the provided future panics, or if called within an asynchronous execution context.
Sourcepub fn handle(&self) -> WithDispatch<Handle> ⓘ
pub fn handle(&self) -> WithDispatch<Handle> ⓘ
Get a new handle to spawn futures on the single-threaded Tokio runtime,
in the context of this WithDispatch
’s trace dispatcher.\
Different to the runtime itself, the handle can be sent to different threads.
The instrumented handle functions identically to a
tokio::runtime::current_thread::Handle
, but the spawned
futures are run in the context of the trace dispatcher.
Source§impl<T> WithDispatch<T>
impl<T> WithDispatch<T>
Sourcepub fn with_dispatch<U>(&self, inner: U) -> WithDispatch<U> ⓘ
pub fn with_dispatch<U>(&self, inner: U) -> WithDispatch<U> ⓘ
Wrap a future, stream, sink or executor with the same subscriber as this WithDispatch.
Sourcepub fn inner_pin_ref(self: Pin<&Self>) -> Pin<&T>
Available on crate feature std-future
only.
pub fn inner_pin_ref(self: Pin<&Self>) -> Pin<&T>
std-future
only.Get a pinned reference to the wrapped type.
Sourcepub fn inner_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T>
Available on crate feature std-future
only.
pub fn inner_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T>
std-future
only.Get a pinned mutable reference to the wrapped type.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the WithDispatch
, returning the wrapped type.
Trait Implementations§
Source§impl<T: Clone> Clone for WithDispatch<T>
impl<T: Clone> Clone for WithDispatch<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T: Debug> Debug for WithDispatch<T>
impl<T: Debug> Debug for WithDispatch<T>
Source§impl<T, F> Executor<F> for WithDispatch<T>
impl<T, F> Executor<F> for WithDispatch<T>
Source§impl<T> Executor for WithDispatch<T>where
T: Executor,
impl<T> Executor for WithDispatch<T>where
T: Executor,
Source§impl<T: Future> Future for WithDispatch<T>
Available on crate feature futures-01
only.
impl<T: Future> Future for WithDispatch<T>
futures-01
only.Source§type Item = <T as Future>::Item
type Item = <T as Future>::Item
Source§type Error = <T as Future>::Error
type Error = <T as Future>::Error
Source§fn poll(&mut self) -> Poll<Self::Item, Self::Error>
fn poll(&mut self) -> Poll<Self::Item, Self::Error>
Source§fn wait(self) -> Result<Self::Item, Self::Error>where
Self: Sized,
fn wait(self) -> Result<Self::Item, Self::Error>where
Self: Sized,
Source§fn map<F, U>(self, f: F) -> Map<Self, F>
fn map<F, U>(self, f: F) -> Map<Self, F>
Source§fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
Source§fn from_err<E>(self) -> FromErr<Self, E>
fn from_err<E>(self) -> FromErr<Self, E>
From
for
this future’s Error
, returning a new future. Read moreSource§fn then<F, B>(self, f: F) -> Then<Self, B, F>
fn then<F, B>(self, f: F) -> Then<Self, B, F>
f
. Read moreSource§fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>
Source§fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F>
fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F>
Source§fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future>
fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future>
Source§fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future>where
B: IntoFuture,
Self: Sized,
fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future>where
B: IntoFuture,
Self: Sized,
Source§fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future>
fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future>
Source§fn join3<B, C>(
self,
b: B,
c: C,
) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future>
fn join3<B, C>( self, b: B, c: C, ) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future>
join
, but with more futures.Source§fn join4<B, C, D>(
self,
b: B,
c: C,
d: D,
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join4<B, C, D>(
self,
b: B,
c: C,
d: D,
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
Self: Sized,
join
, but with more futures.Source§fn join5<B, C, D, E>(
self,
b: B,
c: C,
d: D,
e: E,
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join5<B, C, D, E>(
self,
b: B,
c: C,
d: D,
e: E,
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
Self: Sized,
join
, but with more futures.Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. Read moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
Source§impl<T: Future> Future for WithDispatch<T>
Available on crate feature std-future
only.
impl<T: Future> Future for WithDispatch<T>
std-future
only.Source§impl<T> LocalSpawn for WithDispatch<T>where
T: LocalSpawn,
impl<T> LocalSpawn for WithDispatch<T>where
T: LocalSpawn,
Source§fn spawn_local_obj(
&self,
future: LocalFutureObj<'static, ()>,
) -> Result<(), SpawnError>
fn spawn_local_obj( &self, future: LocalFutureObj<'static, ()>, ) -> Result<(), SpawnError>
Spawns a future that will be run to completion.
§Errors
The executor may be unable to spawn tasks. Spawn errors should represent relatively rare scenarios, such as the executor having been shut down so that it is no longer able to accept tasks.
Source§fn status_local(&self) -> Result<(), SpawnError>
fn status_local(&self) -> Result<(), SpawnError>
Determines whether the executor is able to spawn new tasks.
This method will return Ok
when the executor is likely
(but not guaranteed) to accept a subsequent spawn attempt.
Likewise, an Err
return means that spawn
is likely, but
not guaranteed, to yield an error.
Source§impl<T> Spawn for WithDispatch<T>where
T: Spawn,
impl<T> Spawn for WithDispatch<T>where
T: Spawn,
Source§fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>
fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>
Spawns a future that will be run to completion.
§Errors
The executor may be unable to spawn tasks. Spawn errors should represent relatively rare scenarios, such as the executor having been shut down so that it is no longer able to accept tasks.
Source§fn status(&self) -> Result<(), SpawnError>
fn status(&self) -> Result<(), SpawnError>
Determines whether the executor is able to spawn new tasks.
This method will return Ok
when the executor is likely
(but not guaranteed) to accept a subsequent spawn attempt.
Likewise, an Err
return means that spawn
is likely, but
not guaranteed, to yield an error.
Source§impl<T, F> TypedExecutor<F> for WithDispatch<T>where
T: TypedExecutor<WithDispatch<F>>,
impl<T, F> TypedExecutor<F> for WithDispatch<T>where
T: TypedExecutor<WithDispatch<F>>,
impl<'pin, T> Unpin for WithDispatch<T>where
PinnedFieldsOf<__WithDispatch<'pin, T>>: Unpin,
Auto Trait Implementations§
impl<T> Freeze for WithDispatch<T>where
T: Freeze,
impl<T> !RefUnwindSafe for WithDispatch<T>
impl<T> Send for WithDispatch<T>where
T: Send,
impl<T> Sync for WithDispatch<T>where
T: Sync,
impl<T> !UnwindSafe for WithDispatch<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
Source§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f
. Read moreSource§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
Source§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
Source§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
()
on completion and sends
its output to another future on a separate task. Read moreSource§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
Source§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
Source§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.Source§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§fn into_future(self) -> F
fn into_future(self) -> F
Source§impl<Sp> LocalSpawnExt for Spwhere
Sp: LocalSpawn + ?Sized,
impl<Sp> LocalSpawnExt for Spwhere
Sp: LocalSpawn + ?Sized,
Source§fn spawn_local<Fut>(&self, future: Fut) -> Result<(), SpawnError>
fn spawn_local<Fut>(&self, future: Fut) -> Result<(), SpawnError>
()
to
completion. Read moreSource§fn spawn_local_with_handle<Fut>(
&self,
future: Fut,
) -> Result<RemoteHandle<<Fut as Future>::Output>, SpawnError>where
Fut: Future + 'static,
fn spawn_local_with_handle<Fut>(
&self,
future: Fut,
) -> Result<RemoteHandle<<Fut as Future>::Output>, SpawnError>where
Fut: Future + 'static,
Source§impl<Sp> SpawnExt for Sp
impl<Sp> SpawnExt for Sp
Source§fn spawn<Fut>(&self, future: Fut) -> Result<(), SpawnError>
fn spawn<Fut>(&self, future: Fut) -> Result<(), SpawnError>
()
to
completion. Read moreSource§fn spawn_with_handle<Fut>(
&self,
future: Fut,
) -> Result<RemoteHandle<<Fut as Future>::Output>, SpawnError>
fn spawn_with_handle<Fut>( &self, future: Fut, ) -> Result<RemoteHandle<<Fut as Future>::Output>, SpawnError>
Source§impl<Fut> TryFutureExt for Fut
impl<Fut> TryFutureExt for Fut
Source§fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok>
fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok>
Source§fn map_ok<T, F>(self, f: F) -> MapOk<Self, F>
fn map_ok<T, F>(self, f: F) -> MapOk<Self, F>
Source§fn map_ok_or_else<T, E, F>(self, e: E, f: F) -> MapOkOrElse<Self, F, E>
fn map_ok_or_else<T, E, F>(self, e: E, f: F) -> MapOkOrElse<Self, F, E>
Source§fn map_err<E, F>(self, f: F) -> MapErr<Self, F>
fn map_err<E, F>(self, f: F) -> MapErr<Self, F>
Source§fn and_then<Fut, F>(self, f: F) -> AndThen<Self, Fut, F>
fn and_then<Fut, F>(self, f: F) -> AndThen<Self, Fut, F>
Source§fn or_else<Fut, F>(self, f: F) -> OrElse<Self, Fut, F>
fn or_else<Fut, F>(self, f: F) -> OrElse<Self, Fut, F>
Source§fn inspect_ok<F>(self, f: F) -> InspectOk<Self, F>
fn inspect_ok<F>(self, f: F) -> InspectOk<Self, F>
Source§fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
Source§fn try_flatten(self) -> TryFlatten<Self, Self::Ok>
fn try_flatten(self) -> TryFlatten<Self, Self::Ok>
Source§fn try_flatten_stream(self) -> TryFlattenStream<Self>
fn try_flatten_stream(self) -> TryFlattenStream<Self>
Source§fn unwrap_or_else<F>(self, f: F) -> UnwrapOrElse<Self, F>
fn unwrap_or_else<F>(self, f: F) -> UnwrapOrElse<Self, F>
Source§fn into_future(self) -> IntoFuture<Self>where
Self: Sized,
fn into_future(self) -> IntoFuture<Self>where
Self: Sized,
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
std
only.Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
std
only.