View Source Ash.Type.File.Source protocol (ash v3.4.47)
Protocol for allowing the casting of something into an Ash.Type.File
.
Usage
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
Summary
Functions
Detect Implementation of the file.
Types
@type t() :: term()
All the types that implement this protocol.
Functions
@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.