use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ActionType {
Decision,
Observation,
Mutation,
Delegation,
Revocation,
IdentityOperation,
Custom(String),
}
impl ActionType {
pub fn as_tag(&self) -> &str {
match self {
Self::Decision => "decision",
Self::Observation => "observation",
Self::Mutation => "mutation",
Self::Delegation => "delegation",
Self::Revocation => "revocation",
Self::IdentityOperation => "identity_operation",
Self::Custom(s) => s.as_str(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActionContent {
pub description: String,
pub data: Option<serde_json::Value>,
pub references: Vec<String>,
}
impl ActionContent {
pub fn new(description: impl Into<String>) -> Self {
Self {
description: description.into(),
data: None,
references: Vec::new(),
}
}
pub fn with_data(description: impl Into<String>, data: serde_json::Value) -> Self {
Self {
description: description.into(),
data: Some(data),
references: Vec::new(),
}
}
}