puerto 0.13.0

Puerto — Rust full-stack DDD framework CLI. Scaffolds Clean Architecture projects with auto-wired DI, SQLx support, and zero manual wiring. Formerly puerto-framework.
use async_trait::async_trait;

use crate::domain::shared::repository_error::RepositoryError;
use super::model::{{ "{" }}{{ pascal }}, {{ pascal }}Id};

#[async_trait]
pub trait {{ pascal }}RepositoryTrait: Send + Sync {
    async fn find_by_id(&self, id: {{ pascal }}Id) -> Result<Option<{{ pascal }}>, RepositoryError>;
    async fn save(&self, entity: &{{ pascal }}) -> Result<(), RepositoryError>;
}

#[cfg(any(test, feature = "test-utils"))]
pub mod mocks {
    use mockall::mock;

    use super::*;

    mock! {
        pub {{ pascal }}Repository {}

        #[async_trait]
        impl {{ pascal }}RepositoryTrait for {{ pascal }}Repository {
            async fn find_by_id(&self, id: {{ pascal }}Id) -> Result<Option<{{ pascal }}>, RepositoryError>;
            async fn save(&self, entity: &{{ pascal }}) -> Result<(), RepositoryError>;
        }
    }
}