use async_trait::async_trait;
{% if actor %}use puerto_core::auth::Principal;
{% endif %}{% for imp in extra_imports %}use {{ imp }};
{% endfor %}
use crate::domain::{{ snake }}::{
errors::{{ pascal }}Error,
model::{{ "{" }}{{ pascal }}, {{ pascal }}Id},
};
#[derive(Debug, Clone)]
pub struct Update{{ 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 id: {{ pascal }}Id,
{% for f in params_fields %} pub {{ f.name }}: {{ f.field_type }},
{% endfor %}}
#[async_trait]
pub trait Update{{ pascal }}UseCaseTrait: Send + Sync {
async fn execute(&self, params: Update{{ pascal }}Params) -> Result<{{ pascal }}, {{ pascal }}Error>;
}
#[cfg(any(test, feature = "test-utils"))]
pub mod mocks {
use mockall::mock;
use super::*;
mock! {
pub Update{{ pascal }}UseCase {}
#[async_trait]
impl Update{{ pascal }}UseCaseTrait for Update{{ pascal }}UseCase {
async fn execute(&self, params: Update{{ pascal }}Params) -> Result<{{ pascal }}, {{ pascal }}Error>;
}
}
}