Jido.VFS.Filesystem behaviour (Jido.VFS v1.0.0)

View Source

Behaviour and delegation helpers for a Jido.VFS filesystem module.

Summary

Callbacks

Copies a file from one relative path to another.

Deletes the file at the given relative path.

Checks whether the given relative path exists.

Lists the directory entries for the given relative path.

Moves a file from one relative path to another.

Reads the file at the given relative path.

Opens a readable stream for the file at the given relative path.

Writes contents to the given relative path.

Functions

Injects a filesystem wrapper module backed by a configured adapter.

Merges adapter options with application environment overrides when :otp_app is present.

Merges compile-time options with module-specific runtime configuration and extracts the adapter.

Callbacks

copy(source, destination, opts)

@callback copy(source :: Path.t(), destination :: Path.t(), opts :: keyword()) ::
  :ok | {:error, term()}

Copies a file from one relative path to another.

delete(path, opts)

@callback delete(path :: Path.t(), opts :: keyword()) :: :ok | {:error, term()}

Deletes the file at the given relative path.

file_exists(path, opts)

@callback file_exists(path :: Path.t(), opts :: keyword()) ::
  {:ok, :exists | :missing} | {:error, term()}

Checks whether the given relative path exists.

list_contents(path, opts)

@callback list_contents(path :: Path.t(), opts :: keyword()) ::
  {:ok,
   [
     %Jido.VFS.Stat.Dir{
       mtime: term(),
       name: term(),
       size: term(),
       visibility: term()
     }
     | %Jido.VFS.Stat.File{
         mtime: term(),
         name: term(),
         size: term(),
         visibility: term()
       }
   ]}
  | {:error, term()}

Lists the directory entries for the given relative path.

move(source, destination, opts)

@callback move(source :: Path.t(), destination :: Path.t(), opts :: keyword()) ::
  :ok | {:error, term()}

Moves a file from one relative path to another.

read(path, opts)

@callback read(path :: Path.t(), opts :: keyword()) :: {:ok, binary()} | {:error, term()}

Reads the file at the given relative path.

read_stream(path, opts)

@callback read_stream(path :: Path.t(), opts :: keyword()) ::
  {:ok, Enumerable.t()} | {:error, term()}

Opens a readable stream for the file at the given relative path.

write(path, contents, opts)

@callback write(path :: Path.t(), contents :: binary(), opts :: keyword()) ::
  :ok | {:error, term()}

Writes contents to the given relative path.

Functions

__using__(opts)

(macro)
@spec __using__(Macro.t()) :: Macro.t()

Injects a filesystem wrapper module backed by a configured adapter.

merge_app_env(opts, module)

@spec merge_app_env(
  keyword(),
  module()
) :: keyword()

Merges adapter options with application environment overrides when :otp_app is present.

parse_opts(module, opts)

@spec parse_opts(
  module(),
  keyword()
) :: {module(), keyword()}

Merges compile-time options with module-specific runtime configuration and extracts the adapter.