use crate::domain::record_id::RecordId;

pub trait IdGeneratorPort: Send + Sync {
    fn generate(&self) -> RecordId;
}

pub struct UuidGenerator;

impl IdGeneratorPort for UuidGenerator {
    fn generate(&self) -> RecordId {
        RecordId::new(uuid::Uuid::new_v4().to_string())
    }
}

impl<T: IdGeneratorPort + ?Sized + Send + Sync> IdGeneratorPort for std::sync::Arc<T> {
    fn generate(&self) -> RecordId {
        self.as_ref().generate()
    }
}
