defmodule StellarBase.XDR.SCErrorCode 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 `SCErrorCode` type. """ @behaviour XDR.Declaration @declarations [ SCEC_ARITH_DOMAIN: 0, SCEC_INDEX_BOUNDS: 1, SCEC_INVALID_INPUT: 2, SCEC_MISSING_VALUE: 3, SCEC_EXISTING_VALUE: 4, SCEC_EXCEEDED_LIMIT: 5, SCEC_INVALID_ACTION: 6, SCEC_INTERNAL_ERROR: 7, SCEC_UNEXPECTED_TYPE: 8, SCEC_UNEXPECTED_SIZE: 9 ] @enum_spec %XDR.Enum{declarations: @declarations, identifier: nil} @type t :: %__MODULE__{identifier: atom()} defstruct [:identifier] @spec new(type :: atom()) :: t() def new(type \\ :SCEC_ARITH_DOMAIN), do: %__MODULE__{identifier: type} @impl true def encode_xdr(%__MODULE__{identifier: type}) do @declarations |> XDR.Enum.new(type) |> XDR.Enum.encode_xdr() end @impl true def encode_xdr!(%__MODULE__{identifier: type}) do @declarations |> XDR.Enum.new(type) |> XDR.Enum.encode_xdr!() end @impl true def decode_xdr(bytes, spec \\ @enum_spec) def decode_xdr(bytes, spec) do case XDR.Enum.decode_xdr(bytes, spec) do {:ok, {%XDR.Enum{identifier: type}, rest}} -> {:ok, {new(type), rest}} error -> error end end @impl true def decode_xdr!(bytes, spec \\ @enum_spec) def decode_xdr!(bytes, spec) do {%XDR.Enum{identifier: type}, rest} = XDR.Enum.decode_xdr!(bytes, spec) {new(type), rest} end end