use super::ErrorKind;
#[derive(Clone, Copy)]
pub(super) struct ErrorCodeDefinition {
pub(super) code: i64,
pub(super) kind: ErrorKind,
pub(super) override_kinds: &'static [ErrorKind],
pub(super) retryable: Option<bool>,
pub(super) experimental: bool,
}
impl ErrorCodeDefinition {
pub(super) const fn new(
code: i64,
kind: ErrorKind,
override_kinds: &'static [ErrorKind],
retryable: Option<bool>,
) -> Self {
Self {
code,
kind,
override_kinds,
retryable,
experimental: false,
}
}
pub(super) const fn experimental(code: i64, kind: ErrorKind) -> Self {
Self::experimental_with_retry(code, kind, Some(false))
}
pub(super) const fn experimental_with_retry(
code: i64,
kind: ErrorKind,
retryable: Option<bool>,
) -> Self {
Self {
code,
kind,
override_kinds: &[],
retryable,
experimental: true,
}
}
}
pub(super) const fn fatal(code: i64, kind: ErrorKind) -> ErrorCodeDefinition {
ErrorCodeDefinition::new(code, kind, &[], Some(false))
}
pub(super) const fn drains(code: i64, kind: ErrorKind) -> ErrorCodeDefinition {
ErrorCodeDefinition::new(code, kind, &[], Some(true))
}
pub(super) const fn preempted(code: i64, kind: ErrorKind) -> ErrorCodeDefinition {
ErrorCodeDefinition::new(code, kind, &[], None)
}