pub struct BlockingAsyncProducer<F, Fut>{ /* private fields */ }Expand description
Adapter that wraps an async fn returning a Report and
implements dev_report::Producer by calling
tokio::runtime::Handle::current().block_on(...).
MUST be invoked from a sync context that is not itself running
inside a current_thread runtime. Calling block_on from inside
an async runtime would deadlock; if you need that, use
AsyncProducer directly without going through Producer.
§Example
use dev_async::{run_with_timeout, BlockingAsyncProducer};
use dev_report::{Producer, Report};
use std::time::Duration;
fn build_report() -> impl std::future::Future<Output = Report> {
async {
let check = run_with_timeout("op", Duration::from_millis(50), async {}).await;
let mut r = Report::new("crate", "0.1.0").with_producer("dev-async");
r.push(check);
r.finish();
r
}
}
// From a sync test or main:
// let rt = tokio::runtime::Runtime::new().unwrap();
// let handle = rt.handle().clone();
// let producer = BlockingAsyncProducer::new(handle, build_report);
// let report = producer.produce();Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<F, Fut> Freeze for BlockingAsyncProducer<F, Fut>where
F: Freeze,
impl<F, Fut> RefUnwindSafe for BlockingAsyncProducer<F, Fut>where
F: RefUnwindSafe,
impl<F, Fut> Send for BlockingAsyncProducer<F, Fut>where
F: Send,
impl<F, Fut> Sync for BlockingAsyncProducer<F, Fut>where
F: Sync,
impl<F, Fut> Unpin for BlockingAsyncProducer<F, Fut>where
F: Unpin,
impl<F, Fut> UnsafeUnpin for BlockingAsyncProducer<F, Fut>where
F: UnsafeUnpin,
impl<F, Fut> UnwindSafe for BlockingAsyncProducer<F, Fut>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