conch_runtime_pshaw/spawn/ast_impl/
and_or.rs1use crate::env::{LastStatusEnvironment, ReportErrorEnvironment};
2use crate::error::IsFatalError;
3use crate::spawn::{and_or_list, AndOr, ExitStatus, Spawn};
4use conch_parser::ast;
5use futures_core::future::BoxFuture;
6
7impl<T> From<ast::AndOr<T>> for AndOr<T> {
8 fn from(and_or: ast::AndOr<T>) -> Self {
9 match and_or {
10 ast::AndOr::And(t) => AndOr::And(t),
11 ast::AndOr::Or(t) => AndOr::Or(t),
12 }
13 }
14}
15
16impl<T, E> Spawn<E> for ast::AndOrList<T>
17where
18 T: Sync + Spawn<E>,
19 T::Error: IsFatalError,
20 E: Send + ?Sized + LastStatusEnvironment + ReportErrorEnvironment,
21{
22 type Error = T::Error;
23
24 fn spawn<'life0, 'life1, 'async_trait>(
25 &'life0 self,
26 env: &'life1 mut E,
27 ) -> BoxFuture<'async_trait, Result<BoxFuture<'static, ExitStatus>, Self::Error>>
28 where
29 'life0: 'async_trait,
30 'life1: 'async_trait,
31 Self: 'async_trait,
32 {
33 Box::pin(and_or_list(
34 &self.first,
35 self.rest.iter().map(|ast| match ast {
36 ast::AndOr::And(and) => AndOr::And(and),
37 ast::AndOr::Or(or) => AndOr::Or(or),
38 }),
39 env,
40 ))
41 }
42}