Skip to main content

require_ci

Function require_ci 

Source
pub fn require_ci(caixa: &Caixa) -> Result<&CiRun, MissingCiSlot>
Expand description

Predicate: assert that caixa.ci().is_some(), returning the borrowed canteiro_types::CiRun on success and a typed MissingCiSlot view (carrying Caixa::nome) on rejection. The canonical entry-point every per-Acao consumer wraps in its own thiserror Error variant via #[from] — the call site becomes a single let ci = caixa_core::require_ci(caixa)?; in place of the prior two-line let ci = caixa.ci().ok_or_else(|| Error::MissingCi { nome: caixa.nome().to_string() })?; block.

Returns &CiRun (rather than () like the peer require_kind and require_single_servico predicates on the same substrate entry-gate axis) because every caller then reaches for the borrowed :ci slot’s canteiro_types::CiRun to decompose / render / emit — projecting the successful borrow through the same ? step folds the check and the bind onto one call site, matching how every present + roadmapped per-Acao consumer uses the slot.

Lifted to a single helper so the :ci-slot-presence gate — the same axis the crate::LayoutError::MissingCi emission gates on at feira build time — lives in exactly one place across every future per-Acao consumer: a future sui-supercacheci::canteiro::emit_gha workflow renderer (the deferred caixa-actions next step named in its own crate docs), a future per-Acao CR materializer, and every consumer downstream reaches for the same typed helper and gets the same named-the-offending-caixa diagnostic for free.

Same trajectory as require_kind / KindMismatch on the peer per-renderer kind-gate axis and require_single_servico / ServicoCountMismatch on the peer per-Servico V0-count-gate axis: one caixa_core::require_* helper per typed entry-gate axis, so the diagnostic shape (named caixa, named field) is uniform across the substrate, and every per-kind renderer’s Error::From<*> #[from] arm gets the diagnostic-naming-the-offending-caixa contract for free.

§Errors

Returns MissingCiSlot when caixa.ci().is_none() — every non-Acao kind lands here (the sibling crate::LayoutError::CiOnNonAcao gate refuses a declared :ci on any other kind at feira build time, so a callsite that gates on :kind Acao first via require_kind will only ever surface this arm for a :kind Acao caixa that hasn’t declared its :ci yet). The error carries the caixa’s :nome so the diagnostic names the offending caixa.lisp — same shape every consumer’s Error::From<MissingCiSlot> converts into the consumer’s local error type.