Trait agnostic_lite::RuntimeLite
source · pub trait RuntimeLite: Sized + Unpin + Copy + Send + Sync + 'static {
Show 42 associated items
type Spawner: AsyncSpawner;
type LocalSpawner: AsyncLocalSpawner;
type BlockingSpawner: AsyncBlockingSpawner;
type AfterSpawner: AsyncAfterSpawner;
type LocalAfterSpawner: AsyncLocalAfterSpawner;
type Interval: AsyncInterval;
type LocalInterval: AsyncLocalInterval;
type Sleep: AsyncSleep;
type LocalSleep: AsyncLocalSleep;
type Delay<F>: AsyncDelay<F>
where F: Future + Send;
type LocalDelay<F>: AsyncLocalDelay<F>
where F: Future;
type Timeout<F>: AsyncTimeout<F>
where F: Future + Send;
type LocalTimeout<F>: AsyncLocalTimeout<F>
where F: Future;
// Required methods
fn new() -> Self;
fn block_on<F: Future>(f: F) -> F::Output;
fn yield_now() -> impl Future<Output = ()> + Send;
fn interval(interval: Duration) -> Self::Interval;
fn interval_at(start: Instant, period: Duration) -> Self::Interval;
fn interval_local(interval: Duration) -> Self::LocalInterval;
fn interval_local_at(
start: Instant,
period: Duration
) -> Self::LocalInterval;
fn sleep(duration: Duration) -> Self::Sleep;
fn sleep_until(instant: Instant) -> Self::Sleep;
fn sleep_local(duration: Duration) -> Self::LocalSleep;
fn sleep_local_until(instant: Instant) -> Self::LocalSleep;
fn delay<F>(duration: Duration, fut: F) -> Self::Delay<F>
where F: Future + Send;
fn delay_local<F>(duration: Duration, fut: F) -> Self::LocalDelay<F>
where F: Future;
fn delay_at<F>(deadline: Instant, fut: F) -> Self::Delay<F>
where F: Future + Send;
fn delay_local_at<F>(deadline: Instant, fut: F) -> Self::LocalDelay<F>
where F: Future;
// Provided methods
fn spawn<F>(
future: F
) -> <Self::Spawner as AsyncSpawner>::JoinHandle<F::Output>
where F::Output: Send + 'static,
F: Future + Send + 'static,
<<Self::Spawner as AsyncSpawner>::JoinHandle<F> as Future>::Output: Send { ... }
fn spawn_detach<F>(future: F)
where F::Output: Send + 'static,
F: Future + Send + 'static { ... }
fn spawn_local<F>(
future: F
) -> <Self::LocalSpawner as AsyncLocalSpawner>::JoinHandle<F::Output>
where F: Future + 'static,
F::Output: 'static { ... }
fn spawn_local_detach<F>(future: F)
where F: Future + 'static,
F::Output: 'static { ... }
fn spawn_blocking<F, R>(
f: F
) -> <Self::BlockingSpawner as AsyncBlockingSpawner>::JoinHandle<R>
where F: FnOnce() -> R + Send + 'static,
R: Send + 'static { ... }
fn spawn_blocking_detach<F, R>(f: F)
where F: FnOnce() -> R + Send + 'static,
R: Send + 'static { ... }
fn spawn_after<F>(
duration: Duration,
future: F
) -> <Self::AfterSpawner as AsyncAfterSpawner>::JoinHandle<F::Output>
where F::Output: Send + 'static,
F: Future + Send + 'static { ... }
fn spawn_after_at<F>(
at: Instant,
future: F
) -> <Self::AfterSpawner as AsyncAfterSpawner>::JoinHandle<F::Output>
where F::Output: Send + 'static,
F: Future + Send + 'static { ... }
fn spawn_local_after<F>(
duration: Duration,
future: F
) -> <Self::LocalAfterSpawner as AsyncLocalAfterSpawner>::JoinHandle<F::Output>
where F::Output: Send + 'static,
F: Future + Send + 'static { ... }
fn spawn_local_after_at<F>(
at: Instant,
future: F
) -> <Self::LocalAfterSpawner as AsyncLocalAfterSpawner>::JoinHandle<F::Output>
where F::Output: Send + 'static,
F: Future + Send + 'static { ... }
fn timeout<F>(duration: Duration, future: F) -> Self::Timeout<F>
where F: Future + Send { ... }
fn timeout_at<F>(deadline: Instant, future: F) -> Self::Timeout<F>
where F: Future + Send { ... }
fn timeout_local<F>(duration: Duration, future: F) -> Self::LocalTimeout<F>
where F: Future { ... }
fn timeout_local_at<F>(
deadline: Instant,
future: F
) -> Self::LocalTimeout<F>
where F: Future { ... }
}Expand description
Runtime trait
Required Associated Types§
sourcetype Spawner: AsyncSpawner
type Spawner: AsyncSpawner
The spawner type for this runtime
sourcetype LocalSpawner: AsyncLocalSpawner
type LocalSpawner: AsyncLocalSpawner
The local spawner type for this runtime
sourcetype BlockingSpawner: AsyncBlockingSpawner
type BlockingSpawner: AsyncBlockingSpawner
The blocking spawner type for this runtime
sourcetype AfterSpawner: AsyncAfterSpawner
Available on crate feature time only.
type AfterSpawner: AsyncAfterSpawner
time only.The after spawner type for this runtime
sourcetype LocalAfterSpawner: AsyncLocalAfterSpawner
Available on crate feature time only.
type LocalAfterSpawner: AsyncLocalAfterSpawner
time only.The local after spawner type for this runtime
sourcetype Interval: AsyncInterval
Available on crate feature time only.
type Interval: AsyncInterval
time only.The interval type for this runtime
sourcetype LocalInterval: AsyncLocalInterval
Available on crate feature time only.
type LocalInterval: AsyncLocalInterval
time only.The local interval type for this runtime
sourcetype Sleep: AsyncSleep
Available on crate feature time only.
type Sleep: AsyncSleep
time only.The sleep type for this runtime
sourcetype LocalSleep: AsyncLocalSleep
Available on crate feature time only.
type LocalSleep: AsyncLocalSleep
time only.The local sleep type for this runtime
sourcetype Delay<F>: AsyncDelay<F>
where
F: Future + Send
Available on crate feature time only.
type Delay<F>: AsyncDelay<F> where F: Future + Send
time only.The delay type for this runtime
sourcetype LocalDelay<F>: AsyncLocalDelay<F>
where
F: Future
Available on crate feature time only.
type LocalDelay<F>: AsyncLocalDelay<F> where F: Future
time only.The local delay type for this runtime
sourcetype Timeout<F>: AsyncTimeout<F>
where
F: Future + Send
Available on crate feature time only.
type Timeout<F>: AsyncTimeout<F> where F: Future + Send
time only.The timeout type for this runtime
sourcetype LocalTimeout<F>: AsyncLocalTimeout<F>
where
F: Future
Available on crate feature time only.
type LocalTimeout<F>: AsyncLocalTimeout<F> where F: Future
time only.The local timeout type for this runtime
Required Methods§
sourcefn interval(interval: Duration) -> Self::Interval
Available on crate feature time only.
fn interval(interval: Duration) -> Self::Interval
time only.Create a new interval that starts at the current time and
yields every period duration
sourcefn interval_at(start: Instant, period: Duration) -> Self::Interval
Available on crate feature time only.
fn interval_at(start: Instant, period: Duration) -> Self::Interval
time only.Create a new interval that starts at the given instant and
yields every period duration
sourcefn interval_local(interval: Duration) -> Self::LocalInterval
Available on crate feature time only.
fn interval_local(interval: Duration) -> Self::LocalInterval
time only.Create a new interval that starts at the current time and
yields every period duration
sourcefn interval_local_at(start: Instant, period: Duration) -> Self::LocalInterval
Available on crate feature time only.
fn interval_local_at(start: Instant, period: Duration) -> Self::LocalInterval
time only.Create a new interval that starts at the given instant and
yields every period duration
sourcefn sleep(duration: Duration) -> Self::Sleep
Available on crate feature time only.
fn sleep(duration: Duration) -> Self::Sleep
time only.Create a new sleep future that completes after the given duration has elapsed
sourcefn sleep_until(instant: Instant) -> Self::Sleep
Available on crate feature time only.
fn sleep_until(instant: Instant) -> Self::Sleep
time only.Create a new sleep future that completes at the given instant has elapsed
sourcefn sleep_local(duration: Duration) -> Self::LocalSleep
Available on crate feature time only.
fn sleep_local(duration: Duration) -> Self::LocalSleep
time only.Create a new sleep future that completes after the given duration has elapsed
sourcefn sleep_local_until(instant: Instant) -> Self::LocalSleep
Available on crate feature time only.
fn sleep_local_until(instant: Instant) -> Self::LocalSleep
time only.Create a new sleep future that completes at the given instant has elapsed
sourcefn delay<F>(duration: Duration, fut: F) -> Self::Delay<F>
Available on crate feature time only.
fn delay<F>(duration: Duration, fut: F) -> Self::Delay<F>
time only.Create a new delay future that runs the fut after the given duration
has elapsed. The Future will never be polled until the duration has
elapsed.
The behavior of this function may different in different runtime implementations.
sourcefn delay_local<F>(duration: Duration, fut: F) -> Self::LocalDelay<F>where
F: Future,
Available on crate feature time only.
fn delay_local<F>(duration: Duration, fut: F) -> Self::LocalDelay<F>where
F: Future,
time only.Like delay, but does not require the fut to be Send.
Create a new delay future that runs the fut after the given duration
has elapsed. The Future will never be polled until the duration has
elapsed.
The behavior of this function may different in different runtime implementations.
sourcefn delay_at<F>(deadline: Instant, fut: F) -> Self::Delay<F>
Available on crate feature time only.
fn delay_at<F>(deadline: Instant, fut: F) -> Self::Delay<F>
time only.Create a new timeout future that runs the future after the given deadline.
The Future will never be polled until the deadline has reached.
The behavior of this function may different in different runtime implementations.
sourcefn delay_local_at<F>(deadline: Instant, fut: F) -> Self::LocalDelay<F>where
F: Future,
Available on crate feature time only.
fn delay_local_at<F>(deadline: Instant, fut: F) -> Self::LocalDelay<F>where
F: Future,
time only.Like delay_at, but does not require the fut to be Send.
Create a new timeout future that runs the future after the given deadline
The Future will never be polled until the deadline has reached.
The behavior of this function may different in different runtime implementations.
Provided Methods§
sourcefn spawn<F>(future: F) -> <Self::Spawner as AsyncSpawner>::JoinHandle<F::Output>where
F::Output: Send + 'static,
F: Future + Send + 'static,
<<Self::Spawner as AsyncSpawner>::JoinHandle<F> as Future>::Output: Send,
fn spawn<F>(future: F) -> <Self::Spawner as AsyncSpawner>::JoinHandle<F::Output>where
F::Output: Send + 'static,
F: Future + Send + 'static,
<<Self::Spawner as AsyncSpawner>::JoinHandle<F> as Future>::Output: Send,
Spawn a future onto the runtime
sourcefn spawn_detach<F>(future: F)
fn spawn_detach<F>(future: F)
Spawn a future onto the runtime and detach it
sourcefn spawn_local<F>(
future: F
) -> <Self::LocalSpawner as AsyncLocalSpawner>::JoinHandle<F::Output>
fn spawn_local<F>( future: F ) -> <Self::LocalSpawner as AsyncLocalSpawner>::JoinHandle<F::Output>
Spawn a future onto the local runtime
sourcefn spawn_local_detach<F>(future: F)
fn spawn_local_detach<F>(future: F)
Spawn a future onto the local runtime and detach it
sourcefn spawn_blocking<F, R>(
f: F
) -> <Self::BlockingSpawner as AsyncBlockingSpawner>::JoinHandle<R>
fn spawn_blocking<F, R>( f: F ) -> <Self::BlockingSpawner as AsyncBlockingSpawner>::JoinHandle<R>
Spawn a blocking function onto the runtime
sourcefn spawn_blocking_detach<F, R>(f: F)
fn spawn_blocking_detach<F, R>(f: F)
Spawn a blocking function onto the runtime and detach it
sourcefn spawn_after<F>(
duration: Duration,
future: F
) -> <Self::AfterSpawner as AsyncAfterSpawner>::JoinHandle<F::Output>
Available on crate feature time only.
fn spawn_after<F>( duration: Duration, future: F ) -> <Self::AfterSpawner as AsyncAfterSpawner>::JoinHandle<F::Output>
time only.Spawn a future onto the runtime and run the given future after the given duration
sourcefn spawn_after_at<F>(
at: Instant,
future: F
) -> <Self::AfterSpawner as AsyncAfterSpawner>::JoinHandle<F::Output>
Available on crate feature time only.
fn spawn_after_at<F>( at: Instant, future: F ) -> <Self::AfterSpawner as AsyncAfterSpawner>::JoinHandle<F::Output>
time only.Spawn a future onto the runtime and run the given future after the given instant.
sourcefn spawn_local_after<F>(
duration: Duration,
future: F
) -> <Self::LocalAfterSpawner as AsyncLocalAfterSpawner>::JoinHandle<F::Output>
Available on crate feature time only.
fn spawn_local_after<F>( duration: Duration, future: F ) -> <Self::LocalAfterSpawner as AsyncLocalAfterSpawner>::JoinHandle<F::Output>
time only.Like spawn_after, but does not require the future to be Send.
Spawn a future onto the runtime and run the given future after the given duration
sourcefn spawn_local_after_at<F>(
at: Instant,
future: F
) -> <Self::LocalAfterSpawner as AsyncLocalAfterSpawner>::JoinHandle<F::Output>
Available on crate feature time only.
fn spawn_local_after_at<F>( at: Instant, future: F ) -> <Self::LocalAfterSpawner as AsyncLocalAfterSpawner>::JoinHandle<F::Output>
time only.Like spawn_after_at, but does not require the future to be Send.
Spawn a future onto the runtime and run the given future after the given instant.
sourcefn timeout<F>(duration: Duration, future: F) -> Self::Timeout<F>
Available on crate feature time only.
fn timeout<F>(duration: Duration, future: F) -> Self::Timeout<F>
time only.Requires a Future to complete before the specified duration has elapsed.
The behavior of this function may different in different runtime implementations.
sourcefn timeout_at<F>(deadline: Instant, future: F) -> Self::Timeout<F>
Available on crate feature time only.
fn timeout_at<F>(deadline: Instant, future: F) -> Self::Timeout<F>
time only.Requires a Future to complete before the specified instant in time.
The behavior of this function may different in different runtime implementations.
sourcefn timeout_local<F>(duration: Duration, future: F) -> Self::LocalTimeout<F>where
F: Future,
Available on crate feature time only.
fn timeout_local<F>(duration: Duration, future: F) -> Self::LocalTimeout<F>where
F: Future,
time only.Like timeout, but does not requrie the future to be Send.
Requires a Future to complete before the specified duration has elapsed.
The behavior of this function may different in different runtime implementations.
sourcefn timeout_local_at<F>(deadline: Instant, future: F) -> Self::LocalTimeout<F>where
F: Future,
Available on crate feature time only.
fn timeout_local_at<F>(deadline: Instant, future: F) -> Self::LocalTimeout<F>where
F: Future,
time only.Like timeout_at, but does not requrie the future to be Send.
Requires a Future to complete before the specified duration has elapsed.
The behavior of this function may different in different runtime implementations.
Object Safety§
Implementors§
source§impl RuntimeLite for AsyncStdRuntime
Available on crate feature async-std only.
impl RuntimeLite for AsyncStdRuntime
async-std only.type Spawner = AsyncStdSpawner
type LocalSpawner = AsyncStdSpawner
type BlockingSpawner = AsyncStdSpawner
type AfterSpawner = AsyncStdSpawner
type LocalAfterSpawner = AsyncStdSpawner
type Interval = Timer
type LocalInterval = Timer
type Sleep = AsyncIoSleep
type LocalSleep = AsyncIoSleep
type Delay<F> = Delay<F, AsyncIoSleep> where F: Future + Send
type LocalDelay<F> = Delay<F, AsyncIoSleep> where F: Future
type Timeout<F> = AsyncIoTimeout<F> where F: Future + Send
type LocalTimeout<F> = AsyncIoTimeout<F> where F: Future
source§impl RuntimeLite for SmolRuntime
Available on crate feature smol only.
impl RuntimeLite for SmolRuntime
smol only.type Spawner = SmolSpawner
type LocalSpawner = SmolSpawner
type BlockingSpawner = SmolSpawner
type AfterSpawner = SmolSpawner
type LocalAfterSpawner = SmolSpawner
type Interval = Timer
type LocalInterval = Timer
type Sleep = AsyncIoSleep
type LocalSleep = AsyncIoSleep
type Delay<F> = Delay<F, AsyncIoSleep> where F: Future + Send
type LocalDelay<F> = Delay<F, AsyncIoSleep> where F: Future
type Timeout<F> = AsyncIoTimeout<F> where F: Future + Send
type LocalTimeout<F> = AsyncIoTimeout<F> where F: Future
source§impl RuntimeLite for TokioRuntime
Available on crate feature tokio only.
impl RuntimeLite for TokioRuntime
tokio only.type Spawner = TokioSpawner
type LocalSpawner = TokioSpawner
type BlockingSpawner = TokioSpawner
type AfterSpawner = TokioSpawner
type LocalAfterSpawner = TokioSpawner
type Interval = TokioInterval
type LocalInterval = TokioInterval
type Sleep = TokioSleep
type LocalSleep = TokioSleep
type Delay<F> = Delay<F, TokioSleep> where F: Future + Send
type LocalDelay<F> = Delay<F, TokioSleep> where F: Future
type Timeout<F> = TokioTimeout<F> where F: Future + Send
type LocalTimeout<F> = TokioTimeout<F> where F: Future
source§impl RuntimeLite for WasmRuntime
Available on crate feature wasm only.
impl RuntimeLite for WasmRuntime
wasm only.