refactor: restructure domain crate by bounded context

This commit is contained in:
2026-05-31 04:44:48 +02:00
parent 2b62d1ec81
commit de93373b43
136 changed files with 2111 additions and 2096 deletions

View File

@@ -0,0 +1,29 @@
use crate::common::errors::DomainError;
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct Checksum(String);
impl Checksum {
pub fn new(hex: impl Into<String>) -> Result<Self, DomainError> {
let hex = hex.into().to_lowercase();
if hex.len() != 64 {
return Err(DomainError::Validation(
format!("Checksum must be 64 hex characters, got {}", hex.len()),
));
}
if !hex.chars().all(|c| c.is_ascii_hexdigit()) {
return Err(DomainError::Validation(
"Checksum contains non-hex characters".to_string(),
));
}
Ok(Self(hex))
}
pub fn as_str(&self) -> &str { &self.0 }
}
impl std::fmt::Display for Checksum {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}