Skip to main content

LocalRuntimeLite

Trait LocalRuntimeLite 

Source
pub trait LocalRuntimeLite:
    Sized
    + Unpin
    + Copy
    + Send
    + Sync
    + 'static {
    type LocalSpawner: AsyncLocalSpawner;
    type BlockingSpawner: AsyncBlockingSpawner;
    type Instant: Instant;
    type LocalInterval: AsyncLocalInterval<Instant = Self::Instant>;
    type LocalSleep: AsyncLocalSleep<Instant = Self::Instant>;
    type LocalDelay<F>: AsyncLocalDelay<F, Instant = Self::Instant>
       where F: Future;
    type LocalTimeout<F>: AsyncLocalTimeout<F, Instant = Self::Instant>
       where F: Future;

Show 17 methods // Required methods fn new() -> Self; fn name() -> &'static str; fn fqname() -> &'static str; fn block_on<F: Future>(f: F) -> F::Output; fn interval_local(interval: Duration) -> Self::LocalInterval; fn interval_local_at( start: Self::Instant, period: Duration, ) -> Self::LocalInterval; fn sleep_local(duration: Duration) -> Self::LocalSleep; fn sleep_local_until(instant: Self::Instant) -> Self::LocalSleep; fn delay_local<F>(duration: Duration, fut: F) -> Self::LocalDelay<F> where F: Future; fn delay_local_at<F>(deadline: Self::Instant, fut: F) -> Self::LocalDelay<F> where F: Future; fn timeout_local<F>(duration: Duration, future: F) -> Self::LocalTimeout<F> where F: Future; fn timeout_local_at<F>( deadline: Self::Instant, future: F, ) -> Self::LocalTimeout<F> where F: Future; // Provided methods 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 now() -> Self::Instant { ... }
}
Expand description

The thread-pinned half of a runtime: construction, block_on, local and blocking spawning, and the !Send-tolerant time family.

This is everything a consumer needs to host futures on the current thread. A thread-pinned host — a LocalSet-shaped executor, or any runtime whose timers and join handles are deliberately !Send — can implement this trait even though it can never satisfy RuntimeLite’s Send family; that family lives on RuntimeLite, the extension of this trait.

Deliberately out of scope: completion-based (proactor) runtimes such as compio. Their I/O model wants a native driver integration of its own, not a reactor-shaped runtime abstraction wrapped around it — this crate does not target them, and the split does not promise them.

The marker type itself is still Send + Sync + Copy: it is a zero-sized tag naming the runtime, not a value of it, so it stays thread-mobile even when everything it spawns is pinned.

Required Associated Types§

Source

type LocalSpawner: AsyncLocalSpawner

The local spawner type for this runtime

Note: an implementation may panic when the current thread has no local-executor context to target — see AsyncLocalSpawner’s contract note for the per-runtime behavior.

Source

type BlockingSpawner: AsyncBlockingSpawner

The blocking spawner type for this runtime

Source

type Instant: Instant

Available on crate feature time only.

The instant type for this runtime

Source

type LocalInterval: AsyncLocalInterval<Instant = Self::Instant>

Available on crate feature time only.

The local interval type for this runtime

Source

type LocalSleep: AsyncLocalSleep<Instant = Self::Instant>

Available on crate feature time only.

The local sleep type for this runtime

Source

type LocalDelay<F>: AsyncLocalDelay<F, Instant = Self::Instant> where F: Future

Available on crate feature time only.

The local delay type for this runtime

Source

type LocalTimeout<F>: AsyncLocalTimeout<F, Instant = Self::Instant> where F: Future

Available on crate feature time only.

The local timeout type for this runtime

Required Methods§

Source

fn new() -> Self

Create a new instance of the runtime

Source

fn name() -> &'static str

Returns the name of the runtime

See also fully qualified name of the runtime

Source

fn fqname() -> &'static str

Returns the fully qualified name of the runtime

See also name of the runtime

Source

fn block_on<F: Future>(f: F) -> F::Output

Block the current thread on the given future

Source

fn interval_local(interval: Duration) -> Self::LocalInterval

Available on crate feature time only.

Create a new interval that starts at the current time and yields every period duration

Source

fn interval_local_at( start: Self::Instant, period: Duration, ) -> Self::LocalInterval

Available on crate feature time only.

Create a new interval that starts at the given instant and yields every period duration

Source

fn sleep_local(duration: Duration) -> Self::LocalSleep

Available on crate feature time only.

Create a new sleep future that completes after the given duration has elapsed

Source

fn sleep_local_until(instant: Self::Instant) -> Self::LocalSleep

Available on crate feature time only.

Create a new sleep future that completes at the given instant has elapsed

Source

fn delay_local<F>(duration: Duration, fut: F) -> Self::LocalDelay<F>
where F: Future,

Available on crate feature 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.

Source

fn delay_local_at<F>(deadline: Self::Instant, fut: F) -> Self::LocalDelay<F>
where F: Future,

Available on crate feature 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.

Source

fn timeout_local<F>(duration: Duration, future: F) -> Self::LocalTimeout<F>
where F: Future,

Available on crate feature 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.

Source

fn timeout_local_at<F>( deadline: Self::Instant, future: F, ) -> Self::LocalTimeout<F>
where F: Future,

Available on crate feature 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.

Provided Methods§

Source

fn spawn_local<F>( future: F, ) -> <Self::LocalSpawner as AsyncLocalSpawner>::JoinHandle<F::Output>
where F: Future + 'static, F::Output: 'static,

Spawn a future onto the local runtime

Source

fn spawn_local_detach<F>(future: F)
where F: Future + 'static, F::Output: 'static,

Spawn a future onto the local runtime and detach it

Source

fn spawn_blocking<F, R>( f: F, ) -> <Self::BlockingSpawner as AsyncBlockingSpawner>::JoinHandle<R>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

Spawn a blocking function onto the runtime

Source

fn spawn_blocking_detach<F, R>(f: F)
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

Spawn a blocking function onto the runtime and detach it

Source

fn now() -> Self::Instant

Available on crate feature time only.

Returns an instant corresponding to “now”.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl LocalRuntimeLite for EmbassyRuntime

Available on crate feature embassy only.
Source§

impl LocalRuntimeLite for SmolRuntime

Available on crate feature smol only.
Source§

impl LocalRuntimeLite for TokioRuntime

Available on crate feature tokio only.
Source§

impl LocalRuntimeLite for WasmRuntime

Available on crate feature wasm only.