feat: model operation outcome guarantees

This commit is contained in:
2026-09-30 05:52:38 +09:00
parent 027555eb4e
commit 6de58da17d
8 changed files with 1105 additions and 150 deletions
+11 -8
View File
@@ -647,14 +647,17 @@ fn dispatch_arm(operation: &Operation) -> TokenStream2 {
.map_err(::wip_interface::DispatchError::InvalidArguments)?;
let decoded = #arguments_ident::decode(arguments)
.map_err(::wip_interface::DispatchError::Decode)?;
let result = implementation.#method_ident(#(#arguments),*)
.map_err(::wip_interface::DispatchError::Host)?;
let encoded = #arguments_ident::encode_result(result)
.map_err(::wip_interface::DispatchError::Encode)?;
descriptor
.validate_result(#operation_name, &encoded)
.map_err(::wip_interface::DispatchError::InvalidResult)?;
::std::result::Result::Ok(encoded)
::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| {
let result = implementation.#method_ident(#(#arguments),*)
.map_err(::wip_interface::DispatchError::Host)?;
let encoded = #arguments_ident::encode_result(result)
.map_err(::wip_interface::DispatchError::Encode)?;
descriptor
.validate_result(#operation_name, &encoded)
.map_err(::wip_interface::DispatchError::InvalidResult)?;
::std::result::Result::Ok(encoded)
}))
.map_err(|_| ::wip_interface::DispatchError::Panic)?
}
}
}