# `ExCodecs.Application`
[🔗](https://github.com/AnimaLogica/codecs/blob/v0.2.4/lib/ex_codecs/application.ex#L1)

OTP Application callback module for ExCodecs.

Starts the shared `ExCodecs.CodecRegistry` catalog and registers all built-in
binary and spatial codecs during application startup.

# `start`

```elixir
@spec start(Application.start_type(), term()) ::
  {:ok, pid()} | {:error, term()} | {:ok, pid(), term()}
```

Starts the ExCodecs supervision tree.

This callback starts `ExCodecs.CodecRegistry`, registers every built-in
codec entry, and supervises the registry with a `:one_for_one`
strategy. It is invoked by OTP when the `:ex_codecs` application starts;
application code should normally use `Application.ensure_all_started/1`
instead of calling this function directly.

## Arguments

  * `type` — `Application.start_type()`. OTP supplies `:normal`,
    `{:takeover, node}`, or `{:failover, node}`; ExCodecs does not vary its
    startup behavior by type.
  * `args` — startup term configured for the application. ExCodecs ignores
    this value.

## Returns

  * `{:ok, supervisor_pid}` when the supervisor and registry start.
  * `{:error, reason}` when `Supervisor.start_link/2` cannot start the
    supervision tree.
  * `{:ok, supervisor_pid, state}` is permitted by the
    `Application.start/2` callback contract, but ExCodecs does not currently
    return that form.

## Raises

This callback does not deliberately raise. OTP or supervisor internals may
exit the calling process for unrecoverable startup failures.

## Example

    iex> {:ok, _apps} = Application.ensure_all_started(:ex_codecs)
    iex> Process.whereis(ExCodecs.Supervisor) |> is_pid()
    true
    iex> ExCodecs.supports?(:zstd)
    true

## Callback implementation

An OTP application that embeds a similar registry can use the same shape.
Note: `ExCodecs.CodecRegistry` registers under a fixed global name, so the
example below is for a **separate** registry module, not a second instance
of the library's own.

    defmodule MyApp.Application do
      use Application

      @impl Application
      def start(_type, _args) do
        children = [{MyApp.CodecRegistry, register: fn -> :ok end}]
        Supervisor.start_link(children,
          strategy: :one_for_one,
          name: MyApp.Supervisor
        )
      end
    end

---

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