pub struct Runtime(/* private fields */);Expand description
A type-erased RuntimeTrait implementation. Think of this as an Arc<dyn RuntimeTrait>
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new(runtime: impl RuntimeTrait) -> Runtime
pub fn new(runtime: impl RuntimeTrait) -> Runtime
Construct a new type-erased runtime object from any RuntimeTrait implementation.
Sourcepub fn spawn<Output>(
&self,
fut: impl Future<Output = Output> + Send + 'static,
) -> DroppableFuture<Pin<Box<dyn Future<Output = Option<Output>> + Send>>>where
Output: Send + 'static,
pub fn spawn<Output>(
&self,
fut: impl Future<Output = Output> + Send + 'static,
) -> DroppableFuture<Pin<Box<dyn Future<Output = Option<Output>> + Send>>>where
Output: Send + 'static,
Spawn a future on the runtime, returning a future that has detach-on-drop semantics
Spawned tasks conform to the following behavior:
-
detach on drop: If the returned
DroppableFutureis dropped immediately, the task will continue to execute until completion. -
unwinding: If the spawned future panics, this must not propagate to the join handle. Instead, the awaiting the join handle returns None in case of panic.
Sourcepub fn interval(&self, period: Duration) -> impl Stream<Item = ()> + Send
pub fn interval(&self, period: Duration) -> impl Stream<Item = ()> + Send
Returns a Stream that yields a () on the provided period
Trait Implementations§
Source§impl From<RuntimelessRuntime> for Runtime
impl From<RuntimelessRuntime> for Runtime
Source§fn from(value: RuntimelessRuntime) -> Self
fn from(value: RuntimelessRuntime) -> Self
Converts to this type from the input type.
Source§impl From<SmolRuntime> for Runtime
impl From<SmolRuntime> for Runtime
Source§fn from(value: SmolRuntime) -> Runtime
fn from(value: SmolRuntime) -> Runtime
Converts to this type from the input type.
Source§impl RuntimeTrait for Runtime
impl RuntimeTrait for Runtime
Source§fn interval(&self, period: Duration) -> impl Stream<Item = ()> + Send + 'static
fn interval(&self, period: Duration) -> impl Stream<Item = ()> + Send + 'static
Returns a
Stream that yields a () on the provided periodSource§fn spawn<Fut>(
&self,
fut: Fut,
) -> DroppableFuture<impl Future<Output = Option<<Fut as Future>::Output>> + Send + 'static>
fn spawn<Fut>( &self, fut: Fut, ) -> DroppableFuture<impl Future<Output = Option<<Fut as Future>::Output>> + Send + 'static>
Spawn a future on the runtime, returning a future that has detach-on-drop semantics Read more
Source§fn block_on<Fut>(&self, fut: Fut) -> <Fut as Future>::Outputwhere
Fut: Future,
fn block_on<Fut>(&self, fut: Fut) -> <Fut as Future>::Outputwhere
Fut: Future,
Runtime implementation hook for blocking on a top level future.
Source§fn hook_signals(
&self,
signals: impl IntoIterator<Item = i32>,
) -> impl Stream<Item = i32> + Send + 'static
fn hook_signals( &self, signals: impl IntoIterator<Item = i32>, ) -> impl Stream<Item = i32> + Send + 'static
trap and return a
Stream of signals that match the provided signalsAuto Trait Implementations§
impl Freeze for Runtime
impl !RefUnwindSafe for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl UnsafeUnpin for Runtime
impl !UnwindSafe for Runtime
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