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

Behaviour for file implementations that are compatible with `Ash.Type.File`.

# `error`

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

Errors returned by the implementation.

# `source`

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

The source of the file the implementation operates on.

# `t`

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

Any `module()` implementing the `Ash.Type.File.Implementation` behaviour.

# `content_type`
*optional* 

```elixir
@callback content_type(file :: source()) :: {:ok, String.t()} | {:error, error()}
```

Return the MIME content type of the file.

See: `Ash.Type.File.content_type/1`

This callback is optional. If the implementation cannot determine the
content type, this callback can be omitted.

# `filename`
*optional* 

```elixir
@callback filename(file :: source()) :: {:ok, String.t()} | {:error, error()}
```

Return the filename of the file.

See: `Ash.Type.File.filename/1`

This callback is optional. If the implementation cannot determine the
filename, this callback can be omitted.

# `open`

```elixir
@callback open(file :: source(), modes :: [File.mode()]) ::
  {:ok, IO.device()} | {:error, error()}
```

Open `IO.device()` for the file.

See `Ash.Type.File.open/2`

The return pid must point to a process following the
[Erlang I/O Protocol](https://www.erlang.org/doc/apps/stdlib/io_protocol.html)
like `StringIO` or `File`.

# `path`
*optional* 

```elixir
@callback path(file :: source()) :: {:ok, Path.t()} | {:error, error()}
```

Return path of the file on disk.

See: `Ash.Type.File.path/1`

This callback is optional. If the file is not stored on disk, this callback
can be omitted.

---

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