#![doc = include_str!("../README.md")]
pub mod artifact;
pub mod legacy;
pub mod process;
pub mod result;
pub mod spec;
pub mod storage;
pub mod worker;
pub use spec::*;
pub type Error = Box<dyn std::error::Error + Send + Sync>;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub struct Coded {
pub code: &'static str,
pub message: String,
}
impl std::fmt::Display for Coded {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.message)
}
}
impl std::error::Error for Coded {}
pub fn coded(code: &'static str, message: impl Into<String>) -> Error {
Box::new(Coded {
code,
message: message.into(),
})
}
pub fn error_code(error: &Error) -> &'static str {
error
.downcast_ref::<Coded>()
.map_or("runner_error", |c| c.code)
}
pub fn retryable(code: &str) -> bool {
code == "attempt_active"
}