saddle-framework 0.3.34

The single business-facing facade for Saddle applications
//! Legacy managed counterpart for the same grouped-context network harness.
use saddle::ingress::{FailureMessage, ProfuseGwCode, ProfuseGwContext, ProfuseGwFailure, ProfuseGwResponse as Outcome};
use saddle::profusecontract::ExternalFunctionResult;
saddle::business_types! {
    #[derive(Deserialize, saddle::Input)] pub struct Input { value: u64 }
    #[derive(Serialize)] pub struct Output { value: u64 }
    #[derive(Clone, PartialEq, Message)] pub struct PingRequest { #[prost(uint64, tag="1")] value: u64 }
    #[derive(Clone, PartialEq, Message)] pub struct PingResponse { #[prost(uint64, tag="1")] value: u64 }
}
pub enum Code { Dependency }
impl ProfuseGwCode for Code {
    const REGISTERED_CODES: &'static [&'static str] = &["DEPENDENCY"];
    fn stable_code(&self) -> &'static str { "DEPENDENCY" }
}
async fn handler(input: &Input, _: ProfuseGwContext, mut external: External,
    _: saddle::BusinessConfig<()>) -> Outcome<Output, Code> {
    match external.ping(PingRequest { value: input.value }).await {
        ExternalFunctionResult::Completed(value) => Outcome::success(Output { value: value.value }),
        ExternalFunctionResult::TechnicalFailure(_) => Outcome::failure(ProfuseGwFailure::new(
            Code::Dependency, FailureMessage::new("dependency unavailable").unwrap())),
    }
}
saddle::application! {
    schema "saddle-application/2";
    application LegacyContextApplication;
    deployment_app "legacy-context-fixture";
    business_config ();
    profusecontract {
        contract_dir "../../tests/e2e/consumers/request-context/consumer/contracts";
        capability External; response_code Code;
        functions { PingCall => ping { business_unit "sample"; function "ping"; } (PingRequest) -> PingResponse; }
    }
    service Legacy { ingress profusegw; operation_type "legacy"; request Input; response Output; handler handler; uses PingCall; }
}
#[test]
fn formal_legacy_graph() { let _: fn() -> saddle::Result<()> = LegacyContextApplication::run; }