Skip to main content

Runtime

Struct Runtime 

Source
pub struct Runtime(/* private fields */);
Expand description

A type-erased RuntimeTrait implementation. Think of this as an Arc<dyn RuntimeTrait>

Implementations§

Source§

impl Runtime

Source

pub fn new(runtime: impl RuntimeTrait) -> Self

Construct a new type-erased runtime object from any RuntimeTrait implementation.

Source

pub fn spawn<Output: Send + 'static>( &self, fut: impl Future<Output = Output> + Send + 'static, ) -> DroppableFuture<Pin<Box<dyn Future<Output = Option<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 DroppableFuture is 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.

Source

pub async fn delay(&self, duration: Duration)

Wake in this amount of wall time

Source

pub fn interval(&self, period: Duration) -> impl Stream<Item = ()> + Send + '_

Returns a Stream that yields a () on the provided period

Source

pub fn block_on<Fut>(&self, fut: Fut) -> Fut::Output
where Fut: Future,

Runtime implementation hook for blocking on a top level future.

Source

pub async fn timeout<Fut>( &self, duration: Duration, fut: Fut, ) -> Option<Fut::Output>
where Fut: Future + Send, Fut::Output: Send + 'static,

Race a future against the provided duration, returning None in case of timeout.

Trait Implementations§

Source§

impl Clone for Runtime

Source§

fn clone(&self) -> Runtime

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Runtime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<R: RuntimeTrait> From<Arc<R>> for Runtime

Source§

fn from(value: Arc<R>) -> Self

Converts to this type from the input type.
Source§

impl RuntimeTrait for Runtime

Source§

async fn delay(&self, duration: Duration)

Wake in this amount of wall time
Source§

fn interval(&self, period: Duration) -> impl Stream<Item = ()> + Send + 'static

Returns a Stream that yields a () on the provided period
Source§

fn spawn<Fut>( &self, fut: Fut, ) -> DroppableFuture<impl Future<Output = Option<Fut::Output>> + Send + 'static>
where Fut: Future + Send + 'static, Fut::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::Output
where 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

trap and return a Stream of signals that match the provided signals
Source§

fn timeout<'runtime, 'fut, Fut>( &'runtime self, duration: Duration, fut: Fut, ) -> impl Future<Output = Option<Fut::Output>> + Send + 'fut
where Fut: Future + Send + 'fut, Fut::Output: Send + 'static, 'runtime: 'fut,

Race a future against the provided duration, returning None in case of timeout.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.