use super::{ChainLink, ChainValidation};
use crate::DkimResult;
pub type ArcResult = DkimResult;
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct ArcOutput<'x> {
pub(crate) result: ArcResult,
pub(crate) set: Vec<ChainLink<'x>>,
}
impl ArcOutput<'_> {
pub fn result(&self) -> &ArcResult {
&self.result
}
pub fn chain(&self) -> &[ChainLink<'_>] {
&self.set
}
}
impl<'x> ArcOutput<'x> {
pub(crate) fn with_result(mut self, result: ArcResult) -> Self {
self.result = result;
self
}
pub fn can_be_sealed(&self) -> bool {
self.set.is_empty() || self.set.last().unwrap().seal.header.cv != ChainValidation::Fail
}
}
impl From<ArcResult> for ArcOutput<'_> {
fn from(result: ArcResult) -> Self {
ArcOutput {
result,
set: Vec::new(),
}
}
}
impl Default for ArcOutput<'_> {
fn default() -> Self {
Self {
result: DkimResult::None,
set: Vec::new(),
}
}
}