[][src]Trait conch_runtime::spawn::Spawn

pub trait Spawn<E: ?Sized> {
    type EnvFuture: EnvFuture<E, Item = Self::Future, Error = Self::Error>;
    type Future: Future<Item = ExitStatus, Error = Self::Error>;
    type Error;
    fn spawn(self, env: &E) -> Self::EnvFuture;
}

A trait for spawning commands into an EnvFuture which can be polled to completion.

Spawning a command is separated into two distinct parts: a future that requires a mutable environment to make progress, and a future which no longer needs any context and can make progress on its own.

This distinction allows a caller to drop an environment as soon as it is no longer needed, which will free up resources, and especially important in preventing deadlocks between pipelines (since the parent process will contain extra reader/writer ends of a pipe and may prevent processes from exiting).

Associated Types

type EnvFuture: EnvFuture<E, Item = Self::Future, Error = Self::Error>

The future that represents spawning the command.

It represents all computations that may need an environment to progress further.

type Future: Future<Item = ExitStatus, Error = Self::Error>

The future that represents the exit status of a fully bootstrapped command, which no longer requires an environment to be driven to completion.

type Error

The type of error that a future will resolve with if it fails in a normal fashion.

Loading content...

Required methods

fn spawn(self, env: &E) -> Self::EnvFuture

Spawn the command as a future.

Although the implementation is free to make any optimizations or pre-computations, there should be no observable side-effects until the very first call to poll on the future. That way a constructed future that was never polled could be dropped without the risk of unintended side effects.

Note: There are no guarantees that the environment will not change between the spawn invocation and the first call to poll() on the future. Thus any optimizations the implementation may decide to make based on the environment should be done with care.

Loading content...

Implementations on Foreign Types

impl<T: ?Sized, E: ?Sized> Spawn<E> for Rc<T> where
    T: 'static + SpawnBoxed<E>,
    E: 'static, 
[src]

type EnvFuture = BoxSpawnEnvFuture<'static, E, Self::Error>

type Future = BoxStatusFuture<'static, Self::Error>

type Error = T::Error

impl<'b, T: ?Sized, E: ?Sized> Spawn<E> for &'b Rc<T> where
    T: 'static + SpawnBoxed<E>,
    E: 'static, 
[src]

type EnvFuture = BoxSpawnEnvFuture<'static, E, Self::Error>

type Future = BoxStatusFuture<'static, Self::Error>

type Error = T::Error

impl<T: ?Sized, E: ?Sized> Spawn<E> for Arc<T> where
    T: 'static + SpawnBoxed<E>,
    E: 'static, 
[src]

type EnvFuture = BoxSpawnEnvFuture<'static, E, Self::Error>

type Future = BoxStatusFuture<'static, Self::Error>

type Error = T::Error

impl<'b, T: ?Sized, E: ?Sized> Spawn<E> for &'b Arc<T> where
    T: 'static + SpawnBoxed<E>,
    E: 'static, 
[src]

type EnvFuture = BoxSpawnEnvFuture<'static, E, Self::Error>

type Future = BoxStatusFuture<'static, Self::Error>

type Error = T::Error

impl<E: ?Sized, T> Spawn<E> for AndOrList<T> where
    E: LastStatusEnvironment + ReportErrorEnvironment,
    T: Spawn<E>,
    T::Error: IsFatalError
[src]

type Error = T::Error

type EnvFuture = AndOrList<T, IntoIter<AndOr<T>>, E>

type Future = ExitResult<T::Future>

impl<'a, E: ?Sized, T> Spawn<E> for &'a AndOrList<T> where
    E: LastStatusEnvironment + ReportErrorEnvironment,
    &'a T: Spawn<E>,
    <&'a T as Spawn<E>>::Error: IsFatalError
[src]

type Error = <&'a T as Spawn<E>>::Error

type EnvFuture = AndOrList<&'a T, AndOrRefIter<Iter<'a, AndOr<T>>>, E>

type Future = ExitResult<<&'a T as Spawn<E>>::Future>

impl<E: ?Sized, T> Spawn<E> for Command<T> where
    E: LastStatusEnvironment,
    T: Spawn<E>,
    T::Error: From<RuntimeError>, 
[src]

type Error = T::Error

type EnvFuture = Command<T::EnvFuture>

type Future = T::Future

impl<'a, E: ?Sized, T> Spawn<E> for &'a Command<T> where
    E: LastStatusEnvironment,
    &'a T: Spawn<E>,
    <&'a T as Spawn<E>>::Error: From<RuntimeError>, 
[src]

type Error = <&'a T as Spawn<E>>::Error

type EnvFuture = Command<<&'a T as Spawn<E>>::EnvFuture>

type Future = <&'a T as Spawn<E>>::Future

impl<S, R, E: ?Sized> Spawn<E> for CompoundCommand<S, R> where
    R: RedirectEval<E, Handle = E::FileHandle>,
    S: Spawn<E>,
    S::Error: From<RedirectionError> + From<R::Error>,
    E: AsyncIoEnvironment + FileDescEnvironment,
    E::FileHandle: Clone + From<FileDesc>, 
[src]

type EnvFuture = LocalRedirections<IntoIter<R>, S, E>

type Future = S::Future

type Error = S::Error

impl<'a, S, R, E: ?Sized> Spawn<E> for &'a CompoundCommand<S, R> where
    &'a R: RedirectEval<E, Handle = E::FileHandle>,
    &'a S: Spawn<E>,
    <&'a S as Spawn<E>>::Error: From<RedirectionError> + From<<&'a R as RedirectEval<E>>::Error>,
    E: AsyncIoEnvironment + FileDescEnvironment,
    E::FileHandle: Clone + From<FileDesc>, 
[src]

type EnvFuture = LocalRedirections<Iter<'a, R>, &'a S, E>

type Future = <&'a S as Spawn<E>>::Future

type Error = <&'a S as Spawn<E>>::Error

impl<T, W, S, E> Spawn<E> for CompoundCommandKind<T, W, S> where
    W: WordEval<E>,
    W::Error: IsFatalError,
    W::EvalResult: Into<E::Var>,
    S: 'static + Spawn<E> + SpawnBoxed<E, Error = <S as Spawn<E>>::Error>,
    <S as Spawn<E>>::Error: From<W::Error> + IsFatalError,
    E: 'static + ArgumentsEnvironment + LastStatusEnvironment + ReportErrorEnvironment + VariableEnvironment + SubEnvironment,
    E::Var: From<E::Arg>,
    E::VarName: Clone + From<T>, 
[src]

impl<'a, T, W, S, E> Spawn<E> for &'a CompoundCommandKind<T, W, S> where
    T: Clone,
    &'a W: WordEval<E>,
    <&'a W as WordEval<E>>::Error: IsFatalError,
    <&'a W as WordEval<E>>::EvalResult: Into<E::Var>,
    &'a S: Spawn<E>,
    <&'a S as Spawn<E>>::Error: IsFatalError,
    <&'a S as Spawn<E>>::Error: From<<&'a W as WordEval<E>>::Error> + IsFatalError,
    E: ArgumentsEnvironment + LastStatusEnvironment + ReportErrorEnvironment + VariableEnvironment + SubEnvironment,
    E::Var: From<E::Arg>,
    E::VarName: Clone + From<T>, 
[src]

type EnvFuture = CompoundCommandKindRefFuture<'a, S, W, E>

type Future = ExitResult<Either<<&'a S as Spawn<E>>::Future, <&'a S as Spawn<E>>::Future>>

type Error = <&'a S as Spawn<E>>::Error

impl<S, E> Spawn<E> for ListableCommand<S> where
    S: Spawn<E>,
    S::Error: From<Error>,
    E: FileDescEnvironment + SubEnvironment,
    E::FileHandle: From<FileDesc> + Clone
[src]

type EnvFuture = ListableCommand<S, E>

type Future = ExitResult<SpawnedPipeline<S, E>>

type Error = S::Error

impl<'a, S: 'a, E> Spawn<E> for &'a ListableCommand<S> where
    &'a S: Spawn<E>,
    <&'a S as Spawn<E>>::Error: From<Error>,
    E: FileDescEnvironment + SubEnvironment,
    E::FileHandle: From<FileDesc> + Clone
[src]

type EnvFuture = ListableCommand<&'a S, E>

type Future = ExitResult<SpawnedPipeline<&'a S, E>>

type Error = <&'a S as Spawn<E>>::Error

impl<ERR, N, S, C, F, E: ?Sized> Spawn<E> for PipeableCommand<N, S, C, Rc<F>> where
    S: Spawn<E, Error = ERR>,
    C: Spawn<E, Error = ERR>,
    F: 'static + SpawnBoxed<E, Error = ERR>,
    E: FunctionEnvironment,
    E::FnName: From<N>,
    E::Fn: From<Rc<dyn SpawnBoxed<E, Error = ERR> + 'static>>, 
[src]

type EnvFuture = PipeableCommand<N, S::EnvFuture, C::EnvFuture, Rc<dyn SpawnBoxed<E, Error = ERR> + 'static>>

type Future = ExitResult<Either<S::Future, C::Future>>

type Error = ERR

impl<'a, ERR, N, S, C, F, E: ?Sized> Spawn<E> for &'a PipeableCommand<N, S, C, Rc<F>> where
    N: Clone,
    &'a S: Spawn<E, Error = ERR>,
    &'a C: Spawn<E, Error = ERR>,
    F: 'static + SpawnBoxed<E, Error = ERR>,
    E: FunctionEnvironment,
    E::FnName: From<N>,
    E::Fn: From<Rc<dyn SpawnBoxed<E, Error = ERR> + 'static>>, 
[src]

type EnvFuture = PipeableCommand<N, <&'a S as Spawn<E>>::EnvFuture, <&'a C as Spawn<E>>::EnvFuture, Rc<dyn SpawnBoxed<E, Error = ERR> + 'static>>

type Future = ExitResult<Either<<&'a S as Spawn<E>>::Future, <&'a C as Spawn<E>>::Future>>

type Error = ERR

impl<ERR, N, S, C, F, E: ?Sized> Spawn<E> for PipeableCommand<N, S, C, Arc<F>> where
    S: Spawn<E, Error = ERR>,
    C: Spawn<E, Error = ERR>,
    F: 'static + SpawnBoxed<E, Error = ERR> + Send + Sync,
    E: FunctionEnvironment,
    E::FnName: From<N>,
    E::Fn: From<Arc<dyn SpawnBoxed<E, Error = ERR> + Send + Sync + 'static>>, 
[src]

type EnvFuture = PipeableCommand<N, S::EnvFuture, C::EnvFuture, Arc<dyn SpawnBoxed<E, Error = ERR> + Send + Sync + 'static>>

type Future = ExitResult<Either<S::Future, C::Future>>

type Error = ERR

impl<'a, ERR, N, S, C, F, E: ?Sized> Spawn<E> for &'a PipeableCommand<N, S, C, Arc<F>> where
    N: Clone,
    &'a S: Spawn<E, Error = ERR>,
    &'a C: Spawn<E, Error = ERR>,
    F: 'static + SpawnBoxed<E, Error = ERR> + Send + Sync,
    E: FunctionEnvironment,
    E::FnName: From<N>,
    E::Fn: From<Arc<dyn SpawnBoxed<E, Error = ERR> + Send + Sync + 'static>>, 
[src]

type EnvFuture = PipeableCommand<N, <&'a S as Spawn<E>>::EnvFuture, <&'a C as Spawn<E>>::EnvFuture, Arc<dyn SpawnBoxed<E, Error = ERR> + Send + Sync + 'static>>

type Future = ExitResult<Either<<&'a S as Spawn<E>>::Future, <&'a C as Spawn<E>>::Future>>

type Error = ERR

impl<V, W, R, S, E: ?Sized> Spawn<E> for SimpleCommand<V, W, R> where
    R: RedirectEval<E, Handle = E::FileHandle>,
    R::Error: From<RedirectionError>,
    V: Hash + Eq + Borrow<String>,
    W: WordEval<E>,
    S: Clone + Spawn<E>,
    S::Error: From<CommandError> + From<RedirectionError> + From<R::Error> + From<W::Error>,
    E: AsyncIoEnvironment + ExecutableEnvironment + ExportedVariableEnvironment + FileDescEnvironment + FunctionEnvironment<Fn = S> + SetArgumentsEnvironment + UnsetVariableEnvironment + WorkingDirectoryEnvironment,
    E::Arg: From<W::EvalResult>,
    E::Args: From<Vec<E::Arg>>,
    E::FileHandle: FileDescWrapper,
    E::FnName: From<W::EvalResult>,
    E::VarName: Borrow<String> + Clone + From<V>,
    E::Var: Borrow<String> + Clone + From<W::EvalResult>, 
[src]

type EnvFuture = SimpleCommandEnvFuture<R, V, W, E>

type Future = ExitResult<SpawnedSimpleCommand<E::Future, S::Future>>

type Error = S::Error

impl<'a, V, W, R, S, E: ?Sized> Spawn<E> for &'a SimpleCommand<V, W, R> where
    &'a R: RedirectEval<E, Handle = E::FileHandle>,
    <&'a R as RedirectEval<E>>::Error: From<RedirectionError>,
    V: Hash + Eq + Borrow<String> + Clone,
    &'a W: WordEval<E>,
    S: Clone + Spawn<E>,
    S::Error: From<CommandError> + From<RedirectionError> + From<<&'a R as RedirectEval<E>>::Error> + From<<&'a W as WordEval<E>>::Error>,
    E: AsyncIoEnvironment + ExecutableEnvironment + ExportedVariableEnvironment + FileDescEnvironment + FunctionEnvironment<Fn = S> + SetArgumentsEnvironment + UnsetVariableEnvironment + WorkingDirectoryEnvironment,
    E::Arg: From<<&'a W as WordEval<E>>::EvalResult>,
    E::Args: From<Vec<E::Arg>>,
    E::FileHandle: FileDescWrapper,
    E::FnName: From<<&'a W as WordEval<E>>::EvalResult>,
    E::VarName: Borrow<String> + Clone + From<V>,
    E::Var: Borrow<String> + Clone + From<<&'a W as WordEval<E>>::EvalResult>, 
[src]

type EnvFuture = SimpleCommandEnvFuture<&'a R, V, &'a W, E>

type Future = ExitResult<SpawnedSimpleCommand<E::Future, S::Future>>

type Error = S::Error

impl<T, E: ?Sized> Spawn<E> for TopLevelCommand<T> where
    T: 'static + StringWrapper + Display,
    E: 'static + AsyncIoEnvironment + ArgumentsEnvironment<Arg = T> + ExecutableEnvironment + ExportedVariableEnvironment<VarName = T, Var = T> + FileDescEnvironment + FunctionEnvironment + IsInteractiveEnvironment + LastStatusEnvironment + ReportErrorEnvironment + SetArgumentsEnvironment + SubEnvironment + UnsetVariableEnvironment + WorkingDirectoryEnvironment,
    E::Args: From<Vec<E::Arg>>,
    E::FileHandle: FileDescWrapper,
    E::FnName: From<T>,
    E::Fn: Clone + From<Rc<dyn SpawnBoxed<E, Error = RuntimeError> + 'static>> + Spawn<E, Error = RuntimeError>, 
[src]

type EnvFuture = BoxSpawnEnvFuture<'static, E, Self::Error>

type Future = BoxStatusFuture<'static, Self::Error>

type Error = RuntimeError

impl<'a, T: 'a, E: ?Sized> Spawn<E> for &'a TopLevelCommand<T> where
    T: 'static + StringWrapper + Display,
    E: 'static + AsyncIoEnvironment + ArgumentsEnvironment<Arg = T> + ExecutableEnvironment + ExportedVariableEnvironment<VarName = T, Var = T> + FileDescEnvironment + FunctionEnvironment + IsInteractiveEnvironment + LastStatusEnvironment + ReportErrorEnvironment + SetArgumentsEnvironment + SubEnvironment + UnsetVariableEnvironment + WorkingDirectoryEnvironment,
    E::Args: From<Vec<E::Arg>>,
    E::FileHandle: FileDescWrapper,
    E::FnName: From<T>,
    E::Fn: Clone + From<Rc<dyn SpawnBoxed<E, Error = RuntimeError> + 'static>> + Spawn<E, Error = RuntimeError>, 
[src]

type EnvFuture = BoxSpawnEnvFuture<'a, E, Self::Error>

type Future = BoxStatusFuture<'a, Self::Error>

type Error = RuntimeError

impl<T, E: ?Sized> Spawn<E> for AtomicTopLevelCommand<T> where
    T: 'static + StringWrapper + Display + Send + Sync,
    E: 'static + AsyncIoEnvironment + ArgumentsEnvironment<Arg = T> + ExecutableEnvironment + ExportedVariableEnvironment<VarName = T, Var = T> + FileDescEnvironment + FunctionEnvironment + IsInteractiveEnvironment + LastStatusEnvironment + ReportErrorEnvironment + SetArgumentsEnvironment + SubEnvironment + UnsetVariableEnvironment + WorkingDirectoryEnvironment,
    E::Args: From<Vec<E::Arg>>,
    E::FileHandle: FileDescWrapper,
    E::FnName: From<T>,
    E::Fn: Clone + From<Arc<dyn SpawnBoxed<E, Error = RuntimeError> + Send + Sync + 'static>> + Spawn<E, Error = RuntimeError>, 
[src]

type EnvFuture = BoxSpawnEnvFuture<'static, E, Self::Error>

type Future = BoxStatusFuture<'static, Self::Error>

type Error = RuntimeError

impl<'a, T: 'a, E: ?Sized> Spawn<E> for &'a AtomicTopLevelCommand<T> where
    T: 'static + StringWrapper + Display + Send + Sync,
    E: 'static + AsyncIoEnvironment + ArgumentsEnvironment<Arg = T> + ExecutableEnvironment + ExportedVariableEnvironment<VarName = T, Var = T> + FileDescEnvironment + FunctionEnvironment + IsInteractiveEnvironment + LastStatusEnvironment + ReportErrorEnvironment + SetArgumentsEnvironment + SubEnvironment + UnsetVariableEnvironment + WorkingDirectoryEnvironment,
    E::Args: From<Vec<E::Arg>>,
    E::FileHandle: FileDescWrapper,
    E::FnName: From<T>,
    E::Fn: Clone + From<Arc<dyn SpawnBoxed<E, Error = RuntimeError> + Send + Sync + 'static>> + Spawn<E, Error = RuntimeError>, 
[src]

type EnvFuture = BoxSpawnEnvFuture<'a, E, Self::Error>

type Future = BoxStatusFuture<'a, Self::Error>

type Error = RuntimeError

impl<'a, 'b: 'a, T, E: ?Sized> Spawn<E> for &'a &'b T where
    &'b T: Spawn<E>, 
[src]

type EnvFuture = <&'b T as Spawn<E>>::EnvFuture

type Future = <&'b T as Spawn<E>>::Future

type Error = <&'b T as Spawn<E>>::Error

impl<E: ?Sized, T: Spawn<E>> Spawn<E> for Box<T>[src]

type EnvFuture = T::EnvFuture

type Future = T::Future

type Error = T::Error

impl<'a, E: ?Sized, T: 'a> Spawn<E> for &'a Box<T> where
    &'a T: Spawn<E>, 
[src]

type EnvFuture = <&'a T as Spawn<E>>::EnvFuture

type Future = <&'a T as Spawn<E>>::Future

type Error = <&'a T as Spawn<E>>::Error

Loading content...

Implementors

impl<E: ?Sized> Spawn<E> for Colon[src]

type EnvFuture = SpawnedColon

type Future = ExitStatus

type Error = Void

impl<E: ?Sized> Spawn<E> for False[src]

type EnvFuture = SpawnedFalse

type Future = ExitStatus

type Error = Void

impl<E: ?Sized> Spawn<E> for True[src]

type EnvFuture = SpawnedTrue

type Future = ExitStatus

type Error = Void

impl<T, I, E: ?Sized> Spawn<E> for Cd<I> where
    T: StringWrapper,
    I: Iterator<Item = T>,
    E: AsyncIoEnvironment + ChangeWorkingDirectoryEnvironment + FileDescEnvironment + ReportErrorEnvironment + VariableEnvironment + WorkingDirectoryEnvironment,
    E::FileHandle: Borrow<FileDesc>,
    E::VarName: Borrow<String> + From<String>,
    E::Var: Borrow<String> + From<String>, 
[src]

type EnvFuture = SpawnedCd<I>

type Future = ExitResult<CdFuture<E::WriteAll>>

type Error = Void

impl<T, I, E: ?Sized> Spawn<E> for Echo<I> where
    T: StringWrapper,
    I: Iterator<Item = T>,
    E: AsyncIoEnvironment,
    E: FileDescEnvironment,
    E: ReportErrorEnvironment,
    E::FileHandle: Borrow<FileDesc>, 
[src]

type EnvFuture = SpawnedEcho<I>

type Future = ExitResult<EchoFuture<E::WriteAll>>

type Error = Void

impl<T, I, E: ?Sized> Spawn<E> for Pwd<I> where
    T: StringWrapper,
    I: Iterator<Item = T>,
    E: AsyncIoEnvironment,
    E: FileDescEnvironment,
    E: ReportErrorEnvironment,
    E::FileHandle: Borrow<FileDesc>,
    E: WorkingDirectoryEnvironment
[src]

type EnvFuture = SpawnedPwd<I>

type Future = ExitResult<PwdFuture<E::WriteAll>>

type Error = Void

impl<T, I, E: ?Sized> Spawn<E> for Shift<I> where
    T: StringWrapper,
    I: Iterator<Item = T>,
    E: ArgumentsEnvironment + ShiftArgumentsEnvironment + ReportErrorEnvironment
[src]

type EnvFuture = SpawnedShift<I>

type Future = ExitStatus

type Error = Void

Loading content...