77 lines
2.8 KiB
Rust
77 lines
2.8 KiB
Rust
use super::entities::{
|
|
Asset, AssetMetadata, AssetStack, DerivativeAsset, DerivativeProfile, DuplicateGroup,
|
|
MetadataSource,
|
|
};
|
|
use crate::common::errors::DomainError;
|
|
use crate::common::value_objects::{Checksum, SystemId};
|
|
use async_trait::async_trait;
|
|
|
|
// --- AssetRepository ---
|
|
|
|
#[async_trait]
|
|
pub trait AssetRepository: Send + Sync {
|
|
async fn find_by_id(&self, id: &SystemId) -> Result<Option<Asset>, DomainError>;
|
|
async fn find_by_checksum(&self, checksum: &Checksum) -> Result<Vec<Asset>, DomainError>;
|
|
async fn find_by_owner(
|
|
&self,
|
|
owner_id: &SystemId,
|
|
limit: u32,
|
|
offset: u32,
|
|
) -> Result<Vec<Asset>, DomainError>;
|
|
async fn save(&self, asset: &Asset) -> Result<(), DomainError>;
|
|
async fn delete(&self, id: &SystemId) -> Result<(), DomainError>;
|
|
}
|
|
|
|
// --- AssetMetadataRepository ---
|
|
|
|
#[async_trait]
|
|
pub trait AssetMetadataRepository: Send + Sync {
|
|
async fn find_by_asset(&self, asset_id: &SystemId) -> Result<Vec<AssetMetadata>, DomainError>;
|
|
async fn find_by_asset_and_source(
|
|
&self,
|
|
asset_id: &SystemId,
|
|
source: MetadataSource,
|
|
) -> Result<Option<AssetMetadata>, DomainError>;
|
|
async fn save(&self, metadata: &AssetMetadata) -> Result<(), DomainError>;
|
|
async fn delete_by_asset_and_source(
|
|
&self,
|
|
asset_id: &SystemId,
|
|
source: MetadataSource,
|
|
) -> Result<(), DomainError>;
|
|
}
|
|
|
|
// --- AssetStackRepository ---
|
|
|
|
#[async_trait]
|
|
pub trait AssetStackRepository: Send + Sync {
|
|
async fn find_by_id(&self, id: &SystemId) -> Result<Option<AssetStack>, DomainError>;
|
|
async fn find_by_asset(&self, asset_id: &SystemId) -> Result<Vec<AssetStack>, DomainError>;
|
|
async fn save(&self, stack: &AssetStack) -> Result<(), DomainError>;
|
|
async fn delete(&self, id: &SystemId) -> Result<(), DomainError>;
|
|
}
|
|
|
|
// --- DerivativeRepository ---
|
|
|
|
#[async_trait]
|
|
pub trait DerivativeRepository: Send + Sync {
|
|
async fn find_by_asset(&self, asset_id: &SystemId)
|
|
-> Result<Vec<DerivativeAsset>, DomainError>;
|
|
async fn find_by_asset_and_profile(
|
|
&self,
|
|
asset_id: &SystemId,
|
|
profile: DerivativeProfile,
|
|
) -> Result<Option<DerivativeAsset>, DomainError>;
|
|
async fn save(&self, derivative: &DerivativeAsset) -> Result<(), DomainError>;
|
|
async fn delete(&self, id: &SystemId) -> Result<(), DomainError>;
|
|
}
|
|
|
|
// --- DuplicateRepository ---
|
|
|
|
#[async_trait]
|
|
pub trait DuplicateRepository: Send + Sync {
|
|
async fn find_by_id(&self, id: &SystemId) -> Result<Option<DuplicateGroup>, DomainError>;
|
|
async fn find_unresolved(&self) -> Result<Vec<DuplicateGroup>, DomainError>;
|
|
async fn find_by_asset(&self, asset_id: &SystemId) -> Result<Vec<DuplicateGroup>, DomainError>;
|
|
async fn save(&self, group: &DuplicateGroup) -> Result<(), DomainError>;
|
|
}
|