astro_run_shared/
runner.rs1use crate::{config, stream::StreamReceiver, WorkflowLogType};
2pub use tokio_stream::{Stream, StreamExt};
3
4#[derive(Debug, Clone)]
5pub enum RunResult {
6 Succeeded,
7 Failed { exit_code: i32 },
8 Cancelled,
9}
10
11#[derive(Debug, Clone)]
12pub struct Log {
13 pub log_type: WorkflowLogType,
14 pub message: String,
15}
16
17impl Log {
18 pub fn log(message: impl Into<String>) -> Self {
19 Self {
20 log_type: WorkflowLogType::Log,
21 message: message.into(),
22 }
23 }
24
25 pub fn error(message: impl Into<String>) -> Self {
26 Self {
27 log_type: WorkflowLogType::Error,
28 message: message.into(),
29 }
30 }
31
32 pub fn is_error(&self) -> bool {
33 self.log_type == WorkflowLogType::Error
34 }
35}
36
37pub type RunResponse = crate::Result<StreamReceiver>;
38
39pub trait Runner {
40 fn run(&self, config: config::Config) -> RunResponse;
41}