use crate::sys;
use crate::xdr::*;
use crate::{CollectAuthHandles, FaultString, HandlingError, library_throw};
#[doc(hidden)]
pub fn contract_return(buf: &[u8], auth_token_ids: &[u32]) -> ! {
crate::storage::live_guards::assert_no_live_guards();
let revert = false;
let auth_token_ids_bytes =
crate::call::auth_handles_as_bytes(auth_token_ids);
sys::raw_Return(buf, revert, auth_token_ids_bytes)
}
#[doc(hidden)]
#[inline]
#[cfg_attr(not(target_arch = "riscv32"), track_caller)]
pub fn contract_return_encoded<RET>(ret: &RET) -> !
where
RET: WriteXDR + ?Sized + CollectAuthHandles,
{
let auth_handles = crate::call::collect_auth_handle_bytes(ret)
.unwrap_or_else(|e| {
library_throw(HandlingError::EncodingSuccess(
FaultString::from_display(e),
));
});
crate::call::with_scratch(|buf| {
crate::internal::encode_scratch(buf, ret)
.unwrap_or_else(|e| crate::exn::encoding_success_throw(e));
contract_return(buf.as_ref(), auth_handles.as_slice());
})
}