View Source Entrepot.Locator (Bonfire v0.9.10-classic-beta.156)

A struct representing a stored file's location and metadata.

The Locator struct contains information about where a file is stored, including its unique identifier, the storage backend used, and any additional metadata.

Summary

Functions

Creates a new Locator struct.

Creates a new Locator struct, raising an error if the input is invalid.

Types

@type t() :: %Entrepot.Locator{id: String.t(), metadata: map(), storage: String.t()}

Functions

Creates a new Locator struct.

Parameters

  • attrs: A map or keyword list of attributes for the Locator.

Returns

  • {:ok, Locator.t()}: A new Locator struct.
  • {:error, String.t()}: An error message if the input is invalid.

Examples

iex> Entrepot.Locator.new(id: "file.txt", storage: Disk)
{:ok, %Entrepot.Locator{id: "file.txt", storage: Disk, metadata: %{}}}

iex> Entrepot.Locator.new(id: 123, storage: Disk)
{:error, "id must be binary"}

Creates a new Locator struct, raising an error if the input is invalid.

Parameters

  • attrs: A map or keyword list of attributes for the Locator.

Returns

  • A new Locator struct.

Raises

Examples

iex> Entrepot.Locator.new!(id: "file.txt", storage: Disk)
%Entrepot.Locator{id: "file.txt", storage: Disk, metadata: %{}}

iex> Entrepot.Locator.new!(id: 123, storage: Disk)
** (Entrepot.Errors.InvalidLocator) id must be binary