#[derive(Copy, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Status {
Draft,
Pending,
Committed,
Ghost,
}
impl Status {
pub fn as_str(&self) -> &'static str {
match self {
Status::Draft => "DRAFT",
Status::Pending => "PENDING",
Status::Committed => "COMMITTED",
Status::Ghost => "GHOST",
}
}
}
use crate::{LogLineError, Status as S};
pub fn ensure(expected_from: S, to: S, current: S) -> Result<(), LogLineError> {
if current != expected_from {
return Err(LogLineError::InvalidTransition { from: current, to });
}
Ok(())
}