# `Trogon.TypeProvider`
[🔗](https://github.com/straw-hat-team/beam-monorepo/blob/trogon_typeprovider@v1.0.0/apps/trogon_typeprovider/lib/trogon/type_provider.ex#L1)

Provides a type mapping system for converting between string type names and Elixir struct modules.

# `import_type_provider`
*macro* 

```elixir
@spec import_type_provider(provider_mod :: module()) :: Macro.t()
```

Imports all the types from another module defined by `Trogon.TypeProvider`.

## Example

    defmodule UserTypeProvider do
      use Trogon.TypeProvider
      # ...
    end

    defmodule MyAppTypeProvider do
      use Trogon.TypeProvider

      import_type_provider UserTypeProvider
    end

# `register_protobuf_message`
*macro* 

```elixir
@spec register_protobuf_message(struct_mod :: module()) :: Macro.t()
```

Registers a mapping from a Protobuf message module using its `full_name/0` function as the type.

This macro requires the Protobuf message module to have a `full_name/0` function that returns
the fully qualified protobuf type name (e.g., "google.protobuf.Timestamp").

To generate protobuf modules with `full_name/0`, ensure your protobuf modules are generated
with the `gen_descriptors=true` option, or define `full_name/0` manually.

## Example

    defmodule MyTypeProvider do
      use Trogon.TypeProvider

      # Registers the module using its full_name/0 as the type
      register_protobuf_message MyApp.Proto.AccountCreated
    end

This is equivalent to:

    register_type "my_app.account_created", MyApp.Proto.AccountCreated

(assuming `MyApp.Proto.AccountCreated.full_name()` returns `"my_app.account_created"`)

# `register_type`
*macro* 

```elixir
@spec register_type(type :: String.t(), struct_mod :: module()) :: Macro.t()
```

Registers a mapping from a type string to an Elixir Module that defines a struct.

## Example

    defmodule MyTypeProvider do
      use Trogon.TypeProvider,
        prefix: "accounts." # optional, adds the prefix to the type

      register_type "account_created", AccountCreated
    end

---

*Consult [api-reference.md](api-reference.md) for complete listing*
