defmodule StellarBase.XDR.Operations.InvokeHostFunction do @moduledoc """ Automatically generated by xdrgen DO NOT EDIT or your changes may be overwritten Target implementation: elixir_xdr at https://hex.pm/packages/elixir_xdr Representation of Stellar `InvokeHostFunction` type. """ @behaviour XDR.Declaration alias StellarBase.XDR.{ HostFunction, SorobanAuthorizationEntryList } @struct_spec XDR.Struct.new( host_function: HostFunction, auth: SorobanAuthorizationEntryList ) @type host_function_type :: HostFunction.t() @type auth_type :: SorobanAuthorizationEntryList.t() @type t :: %__MODULE__{host_function: host_function_type(), auth: auth_type()} defstruct [:host_function, :auth] @spec new(host_function :: host_function_type(), auth :: auth_type()) :: t() def new( %HostFunction{} = host_function, %SorobanAuthorizationEntryList{} = auth ), do: %__MODULE__{host_function: host_function, auth: auth} @impl true def encode_xdr(%__MODULE__{host_function: host_function, auth: auth}) do [host_function: host_function, auth: auth] |> XDR.Struct.new() |> XDR.Struct.encode_xdr() end @impl true def encode_xdr!(%__MODULE__{host_function: host_function, auth: auth}) do [host_function: host_function, auth: auth] |> XDR.Struct.new() |> XDR.Struct.encode_xdr!() end @impl true def decode_xdr(bytes, struct \\ @struct_spec) def decode_xdr(bytes, struct) do case XDR.Struct.decode_xdr(bytes, struct) do {:ok, {%XDR.Struct{components: [host_function: host_function, auth: auth]}, rest}} -> {:ok, {new(host_function, auth), rest}} error -> error end end @impl true def decode_xdr!(bytes, struct \\ @struct_spec) def decode_xdr!(bytes, struct) do {%XDR.Struct{components: [host_function: host_function, auth: auth]}, rest} = XDR.Struct.decode_xdr!(bytes, struct) {new(host_function, auth), rest} end end