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§
Sourcetype LocalSpawner: AsyncLocalSpawner
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.
Sourcetype BlockingSpawner: AsyncBlockingSpawner
type BlockingSpawner: AsyncBlockingSpawner
The blocking spawner type for this runtime
Sourcetype LocalInterval: AsyncLocalInterval<Instant = Self::Instant>
Available on crate feature time only.
type LocalInterval: AsyncLocalInterval<Instant = Self::Instant>
time only.The local interval type for this runtime
Sourcetype LocalSleep: AsyncLocalSleep<Instant = Self::Instant>
Available on crate feature time only.
type LocalSleep: AsyncLocalSleep<Instant = Self::Instant>
time only.The local sleep type for this runtime
Sourcetype LocalDelay<F>: AsyncLocalDelay<F, Instant = Self::Instant>
where
F: Future
Available on crate feature time only.
type LocalDelay<F>: AsyncLocalDelay<F, Instant = Self::Instant> where F: Future
time only.The local delay type for this runtime
Sourcetype LocalTimeout<F>: AsyncLocalTimeout<F, Instant = Self::Instant>
where
F: Future
Available on crate feature time only.
type LocalTimeout<F>: AsyncLocalTimeout<F, Instant = Self::Instant> where F: Future
time only.The local timeout type for this runtime
Required Methods§
Sourcefn name() -> &'static str
fn name() -> &'static str
Returns the name of the runtime
See also fully qualified name of the runtime
Sourcefn fqname() -> &'static str
fn fqname() -> &'static str
Returns the fully qualified name of the runtime
See also name of the runtime
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: Self::Instant,
period: Duration,
) -> Self::LocalInterval
Available on crate feature time only.
fn interval_local_at( start: Self::Instant, period: Duration, ) -> Self::LocalInterval
time only.Create a new interval that starts at the given instant and
yields every period duration
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: Self::Instant) -> Self::LocalSleep
Available on crate feature time only.
fn sleep_local_until(instant: Self::Instant) -> Self::LocalSleep
time only.Create a new sleep future that completes at the given instant has elapsed
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_local_at<F>(deadline: Self::Instant, fut: F) -> Self::LocalDelay<F>where
F: Future,
Available on crate feature time only.
fn delay_local_at<F>(deadline: Self::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.
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: Self::Instant,
future: F,
) -> Self::LocalTimeout<F>where
F: Future,
Available on crate feature time only.
fn timeout_local_at<F>(
deadline: Self::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.
Provided Methods§
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
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.
impl LocalRuntimeLite for EmbassyRuntime
embassy only.type LocalSpawner = EmbassySpawner
type BlockingSpawner = EmbassySpawner
type Instant = Instant
type LocalInterval = EmbassyInterval
type LocalSleep = EmbassySleep
type LocalDelay<F> = Delay<F, EmbassySleep> where F: Future
type LocalTimeout<F> = EmbassyTimeout<F> where F: Future
Source§impl LocalRuntimeLite for SmolRuntime
Available on crate feature smol only.
impl LocalRuntimeLite for SmolRuntime
smol only.type LocalSpawner = SmolSpawner
type BlockingSpawner = SmolSpawner
type Instant = Instant
type LocalInterval = Timer
type LocalSleep = AsyncIoSleep
type LocalDelay<F> = Delay<F, AsyncIoSleep> where F: Future
type LocalTimeout<F> = AsyncIoTimeout<F> where F: Future
Source§impl LocalRuntimeLite for TokioRuntime
Available on crate feature tokio only.
impl LocalRuntimeLite for TokioRuntime
tokio only.type LocalSpawner = TokioSpawner
type BlockingSpawner = TokioSpawner
type Instant = Instant
type LocalInterval = TokioInterval
type LocalSleep = TokioSleep
type LocalDelay<F> = Delay<F, TokioSleep> where F: Future
type LocalTimeout<F> = TokioTimeout<F> where F: Future
Source§impl LocalRuntimeLite for WasmRuntime
Available on crate feature wasm only.
impl LocalRuntimeLite for WasmRuntime
wasm only.