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 `InvokeHostFunctionOp` type.
"""
@behaviour XDR.Declaration
alias StellarBase.XDR.HostFunctionList100
@struct_spec XDR.Struct.new(functions: HostFunctionList100)
@type functions_type :: HostFunctionList100.t()
@type t :: %__MODULE__{functions: functions_type()}
defstruct [:functions]
@spec new(functions :: functions_type()) :: t()
def new(%HostFunctionList100{} = functions),
do: %__MODULE__{functions: functions}
@impl true
def encode_xdr(%__MODULE__{functions: functions}) do
[functions: functions]
|> XDR.Struct.new()
|> XDR.Struct.encode_xdr()
end
@impl true
def encode_xdr!(%__MODULE__{functions: functions}) do
[functions: functions]
|> 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: [functions: functions]}, rest}} ->
{:ok, {new(functions), rest}}
error ->
error
end
end
@impl true
def decode_xdr!(bytes, struct \\ @struct_spec)
def decode_xdr!(bytes, struct) do
{%XDR.Struct{components: [functions: functions]}, rest} =
XDR.Struct.decode_xdr!(bytes, struct)
{new(functions), rest}
end
end