Skip to main content

stellar_xdr/generated/
invoke_host_function_op.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// InvokeHostFunctionOp is an XDR Struct defined as:
5///
6/// ```text
7/// struct InvokeHostFunctionOp
8/// {
9///     // Host function to invoke.
10///     HostFunction hostFunction;
11///     // Per-address authorizations for this host function.
12///     SorobanAuthorizationEntry auth<>;
13/// };
14/// ```
15///
16#[cfg_attr(feature = "alloc", derive(Default))]
17#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
18#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
19#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
20#[cfg_attr(
21    all(feature = "serde", feature = "alloc"),
22    serde_with::serde_as,
23    derive(serde::Serialize, serde::Deserialize),
24    serde(rename_all = "snake_case")
25)]
26#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
27pub struct InvokeHostFunctionOp {
28    pub host_function: HostFunction,
29    pub auth: VecM<SorobanAuthorizationEntry>,
30}
31
32impl ReadXdr for InvokeHostFunctionOp {
33    #[cfg(feature = "std")]
34    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
35        r.with_limited_depth(|r| {
36            Ok(Self {
37                host_function: HostFunction::read_xdr(r)?,
38                auth: VecM::<SorobanAuthorizationEntry>::read_xdr(r)?,
39            })
40        })
41    }
42}
43
44impl WriteXdr for InvokeHostFunctionOp {
45    #[cfg(feature = "std")]
46    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
47        w.with_limited_depth(|w| {
48            self.host_function.write_xdr(w)?;
49            self.auth.write_xdr(w)?;
50            Ok(())
51        })
52    }
53}