pub struct TracedFuture<F> { /* private fields */ }Expand description
A future wrapper that records each poll as a PollEvent.
Use TracedFuture::run for a convenient way to execute a future
and collect its trace.
If the wrapped future is dropped before it completes, a final event
with PollResult::Cancelled is appended to the trace.
§Examples
use async_reify::TracedFuture;
let (val, trace) = TracedFuture::run(async { 1 + 1 }).await;
assert_eq!(val, 2);
assert!(!trace.events.is_empty());Implementations§
Source§impl<F> TracedFuture<F>where
F: Future,
impl<F> TracedFuture<F>where
F: Future,
Sourcepub fn new(inner: F) -> TracedFuture<F> ⓘ
pub fn new(inner: F) -> TracedFuture<F> ⓘ
Create a new traced future wrapping inner.
§Examples
use async_reify::TracedFuture;
let traced = TracedFuture::new(async { 42 });Sourcepub fn with_label(inner: F, label: &str) -> TracedFuture<F> ⓘ
pub fn with_label(inner: F, label: &str) -> TracedFuture<F> ⓘ
Create a new traced future with a label.
§Examples
use async_reify::TracedFuture;
let traced = TracedFuture::with_label(async { 42 }, "my_step");Sourcepub async fn run(inner: F) -> (<F as Future>::Output, Trace)
pub async fn run(inner: F) -> (<F as Future>::Output, Trace)
Run the future to completion, returning the result and the trace.
This is a convenience wrapper that polls the future through a
TracedFuture and collects all events.
§Examples
use async_reify::{TracedFuture, PollResult};
let (result, trace) = TracedFuture::run(async { "hello" }).await;
assert_eq!(result, "hello");
assert!(matches!(trace.events.last().unwrap().result, PollResult::Ready));Trait Implementations§
Source§impl<F> Drop for TracedFuture<F>
impl<F> Drop for TracedFuture<F>
Source§impl<F> Future for TracedFuture<F>where
F: Future,
impl<F> Future for TracedFuture<F>where
F: Future,
Auto Trait Implementations§
impl<F> Freeze for TracedFuture<F>
impl<F> RefUnwindSafe for TracedFuture<F>where
F: RefUnwindSafe,
impl<F> Send for TracedFuture<F>where
F: Send,
impl<F> Sync for TracedFuture<F>where
F: Sync,
impl<F> Unpin for TracedFuture<F>
impl<F> UnsafeUnpin for TracedFuture<F>
impl<F> UnwindSafe for TracedFuture<F>where
F: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more