# `Ash.Type.File.Source`
[🔗](https://github.com/ash-project/ash/blob/v3.23.1/lib/ash/type/file/source.ex#L5)

Protocol for allowing the casting of something into an `Ash.Type.File`.

## Usage

```elixir
defmodule MyStruct do
  defstruct [:path]

  @behavior Ash.Type.File.Implementation

  @impl Ash.Type.File.Implementation
  def path(%__MODULE__{path: path}), do: {:ok, path}

  @impl Ash.Type.File.Implementation
  def open(%__MODULE__{path: path}, modes), do: File.open(path, modes)

  defimpl Ash.Type.File.Source do
    def implementation(%MyStruct{} = struct), do: {:ok, MyStruct}
  end
end
```

# `t`

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

All the types that implement this protocol.

# `implementation`

```elixir
@spec implementation(t()) :: {:ok, Ash.Type.File.Implementation.t()} | :error
```

Detect Implementation of the file.

Returns an `:ok` tuple with the implementation module if the file is supported
and `:error` otherwise.

---

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