use async_trait::async_trait;
use chrono::{DateTime, Utc};
use crate::domain::location::LocationId;
use crate::domain::transfer::{Transfer, TransferState};
use crate::infra::error::InfraError;
#[derive(Debug, Clone)]
pub struct TransferStatRow {
pub src: LocationId,
pub dest: LocationId,
pub state: TransferState,
pub error_kind: Option<String>,
pub attempt: u32,
pub file_count: usize,
}
#[async_trait]
pub trait TransferStore: Send + Sync {
async fn insert_transfer(&self, transfer: &Transfer) -> Result<(), InfraError>;
async fn update_transfer(&self, transfer: &Transfer) -> Result<(), InfraError>;
async fn queued_transfers(&self, dest: &LocationId) -> Result<Vec<Transfer>, InfraError>;
async fn latest_transfers_by_file(&self, file_id: &str) -> Result<Vec<Transfer>, InfraError>;
async fn failed_transfers(&self) -> Result<Vec<Transfer>, InfraError>;
async fn prune_completed(&self, before: DateTime<Utc>) -> Result<usize, InfraError>;
async fn count_queued(&self) -> Result<usize, InfraError>;
async fn cancel_orphaned_inflight(&self) -> Result<usize, InfraError>;
async fn unblock_dependents(&self, completed_transfer_id: &str) -> Result<usize, InfraError>;
async fn all_pending_transfers(&self) -> Result<Vec<Transfer>, InfraError>;
async fn transfer_stats(&self) -> Result<Vec<TransferStatRow>, InfraError>;
async fn present_counts_by_location(
&self,
) -> Result<std::collections::HashMap<LocationId, usize>, InfraError>;
}