use async_trait::async_trait;
use std::sync::Arc;
use systemprompt_identifiers::UserId;
use crate::repository::RepositoryError;
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct ReassignedRows {
pub tables: Vec<(&'static str, u64)>,
}
impl ReassignedRows {
#[must_use]
pub fn total(&self) -> u64 {
self.tables.iter().map(|(_, n)| *n).sum()
}
}
#[async_trait]
pub trait OwnerReassignment: Send + Sync {
fn domain(&self) -> &'static str;
async fn reassign_owner(
&self,
from: &UserId,
to: &UserId,
) -> Result<ReassignedRows, RepositoryError>;
}
pub type DynOwnerReassignment = Arc<dyn OwnerReassignment>;