use anyhow::{Result, anyhow};
use crate::ContentHash;
pub struct ContentHashDomainService;
impl ContentHashDomainService {
pub fn new() -> Self {
Self
}
pub fn validate(&self, entity: &ContentHash) -> Result<()> {
if entity.hash.is_empty() {
return Err(anyhow!("hash is required"));
}
if entity.storage_key.is_empty() {
return Err(anyhow!("storage_key is required"));
}
Ok(())
}
pub fn can_create(&self, entity: &ContentHash) -> Result<bool> {
self.validate(entity)?;
Ok(true)
}
pub fn can_update(&self, _current: &ContentHash, _updated: &ContentHash) -> Result<bool> {
Ok(true)
}
pub fn can_delete(&self, _entity: &ContentHash) -> Result<bool> {
Ok(true)
}
}
impl Default for ContentHashDomainService {
fn default() -> Self {
Self::new()
}
}