Trait Spawn

pub(crate) trait Spawn {
    // Required method
    fn spawn_obj(
        &self,
        future: FutureObj<'static, ()>,
    ) -> Result<(), SpawnError>;

    // Provided method
    fn status(&self) -> Result<(), SpawnError> { ... }
}
Expand description

The Spawn trait allows for pushing futures onto an executor that will run them to completion.

Required Methods§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

Spawns a future that will be run to completion.

§Errors

The executor may be unable to spawn tasks. Spawn errors should represent relatively rare scenarios, such as the executor having been shut down so that it is no longer able to accept tasks.

Provided Methods§

fn status(&self) -> Result<(), SpawnError>

Determines whether the executor is able to spawn new tasks.

This method will return Ok when the executor is likely (but not guaranteed) to accept a subsequent spawn attempt. Likewise, an Err return means that spawn is likely, but not guaranteed, to yield an error.

Implementations on Foreign Types§

Source§

impl Spawn for AsyncStd

Source§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

Source§

impl Spawn for TokioTp

Source§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

Never fails.

§

impl Spawn for AsyncStdNativeTlsRuntime

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

§

impl Spawn for AsyncStdRustlsRuntime

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

§

impl Spawn for FuturesUnordered<FutureObj<'_, ()>>

§

fn spawn_obj( &self, future_obj: FutureObj<'static, ()>, ) -> Result<(), SpawnError>

§

impl Spawn for LocalSpawner

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

§

fn status(&self) -> Result<(), SpawnError>

§

impl Spawn for PreferredRuntime

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

§

impl Spawn for TokioNativeTlsRuntime

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

§

impl Spawn for TokioRustlsRuntime

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

§

impl<Sp> Spawn for &Sp
where Sp: Spawn + ?Sized,

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

§

fn status(&self) -> Result<(), SpawnError>

§

impl<Sp> Spawn for &mut Sp
where Sp: Spawn + ?Sized,

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

§

fn status(&self) -> Result<(), SpawnError>

§

impl<Sp> Spawn for Box<Sp>
where Sp: Spawn + ?Sized,

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

§

fn status(&self) -> Result<(), SpawnError>

§

impl<Sp> Spawn for Rc<Sp>
where Sp: Spawn + ?Sized,

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

§

fn status(&self) -> Result<(), SpawnError>

§

impl<TaskR, SleepR, CoarseTimeR, TcpR, UnixR, TlsR, UdpR> Spawn for CompoundRuntime<TaskR, SleepR, CoarseTimeR, TcpR, UnixR, TlsR, UdpR>
where TaskR: Spawn,

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

Implementors§

§

impl<Sp> Spawn for Arc<Sp>
where Sp: Spawn + ?Sized,

impl<R: Runtime> Spawn for MockNetRuntime<R>