Skip to main content

ic_backup/model/application_ingress/
mod.rs

1//! Opaque application update declarations under original mutation or observation reservations.
2//!
3//! Applications own codecs, fresh authority, whole-unit safety, original byte/command
4//! custody and qualified outcomes. These passive types grant no dispatch or resend.
5
6use crate::model::application_payload::ApplicationPayloadError as Payload;
7mod payload;
8mod request;
9pub use payload::{
10    ApplicationIngressPayload, MAX_APPLICATION_INGRESS_ARGUMENT_BYTES,
11    MAX_APPLICATION_INGRESS_METHOD_BYTES, MAX_APPLICATION_INGRESS_REPLY_BYTES,
12};
13pub use request::{ApplicationMutationRequest, ApplicationObservationRequest};
14
15use crate::model::{ic_observation::IcObservationRequestError, operation_plan::OperationPlanError};
16use thiserror::Error;
17
18/// Exact opaque update or original reservation admission failed; no spending changes.
19#[derive(Debug, Error)]
20pub enum ApplicationIngressError {
21    /// The receiver or effective routing target is not an admitted application principal.
22    #[error("invalid application ingress principal")]
23    InvalidPrincipal,
24    /// Management ingress must use the closed management request owners.
25    #[error("application ingress cannot target the management canister")]
26    ManagementPrincipal,
27    /// Method must have 1..=128 exact visible ASCII bytes.
28    #[error("invalid application ingress method")]
29    InvalidMethod,
30    /// Opaque arguments exceed the finite owner bound.
31    #[error("application ingress arguments too large")]
32    ArgumentsTooLarge,
33    /// Caller-selected reply ceiling must be 1..=1 MiB and is bound into the original digest.
34    #[error("invalid application ingress reply limit")]
35    InvalidReplyLimit,
36    /// Original journal differs from the complete plan-derived authority.
37    #[error("application ingress authority mismatch")]
38    AuthorityMismatch,
39    /// Effective target differs from the original operation.
40    #[error("application ingress target mismatch")]
41    TargetMismatch,
42    /// Receiver, target, fixed update mode, method, bytes or reply ceiling changed.
43    #[error("application ingress payload mismatch")]
44    PayloadMismatch,
45    /// No original mutation reservation is pending.
46    #[error("application ingress requires a pending mutation")]
47    NoPendingMutation,
48    /// The original mutation was replaced or settled.
49    #[error("application ingress mutation mismatch")]
50    MutationMismatch,
51    /// Recovery is pending; the original mutation cannot be submitted through this lane.
52    #[error("application ingress observation is pending")]
53    ObservationPending,
54    /// Exact separately reserved recovery identity failed admission.
55    #[error(transparent)]
56    Observation(#[from] IcObservationRequestError),
57    /// Original operation cannot be derived.
58    #[error(transparent)]
59    Plan(#[from] OperationPlanError),
60}
61
62#[cfg(test)]
63mod tests;
64
65impl From<crate::model::application_payload::ApplicationPayloadError> for ApplicationIngressError {
66    fn from(error: crate::model::application_payload::ApplicationPayloadError) -> Self {
67        match error {
68            Payload::ArgumentsTooLarge => Self::ArgumentsTooLarge,
69            Payload::InvalidMethod => Self::InvalidMethod,
70            Payload::InvalidPrincipal => Self::InvalidPrincipal,
71            Payload::ManagementPrincipal => Self::ManagementPrincipal,
72        }
73    }
74}