# `Ltix.Deployable`
[🔗](https://github.com/DecoyLex/ltix/blob/main/lib/ltix/deployable.ex#L1)

Protocol for converting your deployment struct to an `Ltix.Deployment`.

Implement it for your deployment struct, and your storage adapter can
return that struct. The `Ltix.LaunchContext` from a launch has your struct.

    defmodule MyApp.ToolDeployment do
      defstruct [:id, :registration_id, :deployment_id, :label]

      defimpl Ltix.Deployable do
        def to_deployment(dep) do
          Ltix.Deployment.new(dep.deployment_id)
        end
      end
    end

`Ltix.Deployment` implements this protocol, so your storage adapter can
also return a `%Deployment{}`. Login and launch return the same error as
`Ltix.Deployment.new/1` for an invalid one.

# `t`

```elixir
@type t() :: term()
```

All the types that implement this protocol.

# `to_deployment`

```elixir
@spec to_deployment(t()) :: {:ok, Ltix.Deployment.t()} | {:error, Exception.t()}
```

Return the `Ltix.Deployment` for the given struct.

Build it with `Ltix.Deployment.new/1`, which validates the fields.

---

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