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