ForgeAbi v1.14.4 ForgeAbi.Util.TypeUrl View Source

quick convertion among type, type_url and type_mod

Link to this section Summary

Functions

Add a type url or a list of type urls to the table

retrieve all types for introspection

Decode the binary inside the Any

Decode the binary inside the Any. Raise if error

Encode a struct and wrap it with Any

Encode a struct and wrap it with Any. Throw exception on error

Retrieve mod by type_url

Initialize the table with prepopulated data

Remove a type_url from the table

Link to this section Functions

Link to this function

add(items) View Source
add([{String.t(), module()}]) :: :ok
add({String.t(), module()}) :: :ok

Add a type url or a list of type urls to the table

Link to this function

add(type_url, mod) View Source
add(String.t(), module()) :: :ok

retrieve all types for introspection.

Link to this function

decode_any(arg1) View Source
decode_any(Google.Protobuf.Any.t() | nil) :: {:error, term()} | {:ok, any()}

Decode the binary inside the Any.

Link to this function

decode_any!(any) View Source
decode_any!(Google.Protobuf.Any.t() | nil) :: any() | no_return()

Decode the binary inside the Any. Raise if error.

Link to this function

encode_any(data, type_url \\ nil) View Source
encode_any(map(), String.t() | nil) ::
  {:ok, Google.Protobuf.Any.t()} | {:error, term()}

Encode a struct and wrap it with Any.

Link to this function

encode_any!(data, type_url \\ nil) View Source
encode_any!(map(), String.t() | nil) :: Google.Protobuf.Any.t() | no_return()

Encode a struct and wrap it with Any. Throw exception on error.

Link to this function

get(key) View Source
get(String.t() | module() | nil) :: module() | String.t() | nil

Retrieve mod by type_url

iex> ForgeAbi.Util.TypeUrl.add("fg:t:declare", ForgeAbi.DeclareTx) iex> ForgeAbi.Util.TypeUrl.get("fg:t:declare") ForgeAbi.DeclareTx

iex> ForgeAbi.Util.TypeUrl.add("fg:s:account", ForgeAbi.AccountState) iex> ForgeAbi.Util.TypeUrl.get("fg:s:account") ForgeAbi.AccountState

Initialize the table with prepopulated data

Link to this function

remove(type_url) View Source
remove(String.t()) :: :ok

Remove a type_url from the table