puerto 0.23.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.
// GENERADO por puerto. Edita puerto.toml y después ejecuta `puerto generar bootstrap`.
//! Los repositorios, unidades de trabajo y casos de uso de cada contexto, construidos para los
//! binarios (ADR-0023 § 7 de Puerto). Aquí no hay HTTP: `api` monta sus rutas sobre estos casos de
//! uso.
{% for entity in entities %}
pub mod {{ entity.snake }} {
{%- if entity.use_cases %}
    use std::sync::Arc;

{% for uc in entity.use_cases %}    use aplicacion_{{ entity.snake }}::{{ uc.action }}::{{ "{" }}{{ uc.uc_pascal }}Impl, {{ uc.uc_pascal }}};
{% endfor %}{% if entity.needs_repository %}    use dominio_{{ entity.snake }}::repositorio::Repositorio{{ entity.pascal }};
{% endif %}{% if entity.needs_uow %}    use dominio_{{ entity.snake }}::unit_of_work::UnitOfWorkFactory{{ entity.pascal }};
{% endif %}{% if entity.needs_repository %}    use infra_{{ entity.snake }}::repositorio::Repositorio{{ entity.pascal }}{% if entity.db %}Postgres{% else %}EnMemoria{% endif %};
{% endif %}{% if entity.needs_uow %}    use infra_{{ entity.snake }}::unit_of_work::UnitOfWorkFactory{{ entity.pascal }}Postgres;
{% endif %}{% endif %}
    /// Los casos de uso de `{{ entity.snake }}`, sobre sus adaptadores.
    pub struct CasosDeUso {
{% for uc in entity.use_cases %}        pub {{ uc.action }}: Arc<dyn {{ uc.uc_pascal }}>,
{% endfor %}    }

    pub fn construir({% if entity.db %}{% if entity.use_cases %}pool{% else %}_pool{% endif %}: &sqlx::PgPool{% endif %}) -> CasosDeUso {
{%- if entity.needs_repository %}
        let repositorio: Arc<dyn Repositorio{{ entity.pascal }}> = Arc::new({% if entity.db %}Repositorio{{ entity.pascal }}Postgres::new(pool.clone()){% else %}Repositorio{{ entity.pascal }}EnMemoria::new(){% endif %});
{%- endif %}
{%- if entity.needs_uow %}
        let uow_factory: Arc<dyn UnitOfWorkFactory{{ entity.pascal }}> = Arc::new(UnitOfWorkFactory{{ entity.pascal }}Postgres::new(pool.clone()));
{%- endif %}
        CasosDeUso {
{%- for uc in entity.use_cases %}
            {{ uc.action }}: Arc::new({{ uc.uc_pascal }}Impl { {% if uc.repository %}repositorio: Arc::clone(&repositorio){% endif %}{% if uc.repository and uc.uow %}, {% endif %}{% if uc.uow %}uow_factory: Arc::clone(&uow_factory){% endif %} }),
{%- endfor %}
        }
    }
}
{% endfor -%}