use std::sync::Arc;
use super::EvidenceValidationError;
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
pub struct AxisIndex(usize);
impl AxisIndex {
pub const fn new(index: usize) -> Self {
Self(index)
}
pub const fn index(self) -> usize {
self.0
}
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
pub struct RuleId(&'static str);
impl RuleId {
pub(crate) const fn registered(value: &'static str) -> Self {
Self(value)
}
pub const fn as_str(self) -> &'static str {
self.0
}
}
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
pub struct AssertionId(Arc<str>);
impl AssertionId {
pub fn try_new(value: impl Into<Arc<str>>) -> Result<Self, EvidenceValidationError> {
let value = value.into();
if value.trim().is_empty() {
return Err(EvidenceValidationError::EmptyIdentifier);
}
Ok(Self(value))
}
pub fn as_str(&self) -> &str {
&self.0
}
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
pub struct DerivationStepId(&'static str);
impl DerivationStepId {
pub(crate) const fn registered(value: &'static str) -> Self {
Self(value)
}
pub const fn as_str(self) -> &'static str {
self.0
}
}
impl AssertionId {
#[allow(clippy::type_complexity)]
pub(crate) fn model_parts(&self) -> (&Arc<str>,) {
(&self.0,)
}
#[allow(clippy::type_complexity)]
pub(crate) fn from_model_parts(
parts: (Arc<str>,),
) -> Result<Self, crate::internal::ModelError> {
let (f0,) = parts;
let value = Self(f0);
if value.0.trim().is_empty() {
return Err(crate::internal::ModelError::Structure);
}
Ok(value)
}
}
impl AxisIndex {
#[allow(clippy::type_complexity)]
pub(crate) fn model_parts(&self) -> (&usize,) {
(&self.0,)
}
#[allow(clippy::type_complexity)]
pub(crate) fn from_model_parts(parts: (usize,)) -> Result<Self, crate::internal::ModelError> {
let (f0,) = parts;
let value = Self(f0);
Ok(value)
}
}
impl DerivationStepId {
#[allow(clippy::type_complexity)]
pub(crate) fn model_parts(&self) -> (&&'static str,) {
(&self.0,)
}
#[allow(clippy::type_complexity)]
pub(crate) fn from_model_parts(
parts: (&'static str,),
) -> Result<Self, crate::internal::ModelError> {
let (f0,) = parts;
let value = Self(f0);
Ok(value)
}
}
impl RuleId {
#[allow(clippy::type_complexity)]
pub(crate) fn model_parts(&self) -> (&&'static str,) {
(&self.0,)
}
#[allow(clippy::type_complexity)]
pub(crate) fn from_model_parts(
parts: (&'static str,),
) -> Result<Self, crate::internal::ModelError> {
let (f0,) = parts;
let value = Self(f0);
Ok(value)
}
}