puerto 0.19.1

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;
{% if actor %}use puerto_core::auth::Principal;
{% endif %}use puerto_core::{Page, PageRequest};

use crate::domain::{{ snake }}::{errors::{{ pascal }}Error, model::{{ pascal }}};

#[derive(Debug, Clone)]
pub struct List{{ plural_pascal }}Params {
{% if actor %}    /// Who asks (ADR-0021). A rule that depends on the data ("only the owner edits") decides on
    /// it here and answers `Forbidden`.
    pub actor: Principal,
{% endif %}    pub page: PageRequest,
}

#[async_trait]
pub trait List{{ plural_pascal }}UseCaseTrait: Send + Sync {
    async fn execute(&self, params: List{{ plural_pascal }}Params) -> Result<Page<{{ pascal }}>, {{ pascal }}Error>;
}

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

    use super::*;

    mock! {
        pub List{{ plural_pascal }}UseCase {}

        #[async_trait]
        impl List{{ plural_pascal }}UseCaseTrait for List{{ plural_pascal }}UseCase {
            async fn execute(&self, params: List{{ plural_pascal }}Params) -> Result<Page<{{ pascal }}>, {{ pascal }}Error>;
        }
    }
}