Minga.Buffer.SaveIntent (Minga v0.1.0)

Copy Markdown View Source

Captured destination and overwrite policy for an explicit-path save.

The buffer process creates an intent before formatting starts and validates it again when the write commits. This keeps overwrite consent scoped to one target and lets persistence enforce exclusive creation when that target was absent.

Summary

Functions

Creates a non-forced intent for a destination that was absent when requested.

Creates an intent for the buffer's current file.

Creates an explicit overwrite intent for a captured destination.

Validates that an intent has a coherent policy and belongs to the committing buffer.

Types

expectation()

@type expectation() :: :current_file | :absent | :any

origin_path()

@type origin_path() :: String.t() | nil

t()

@type t() :: %Minga.Buffer.SaveIntent{
  expectation: expectation(),
  origin_buffer: pid(),
  origin_path: origin_path(),
  overwrite: boolean(),
  target: String.t()
}

Functions

absent(target, origin_buffer, origin_path)

@spec absent(String.t(), pid(), origin_path()) :: t()

Creates a non-forced intent for a destination that was absent when requested.

current_file(target, origin_path, overwrite, origin_buffer)

@spec current_file(String.t(), String.t(), boolean(), pid()) :: t()

Creates an intent for the buffer's current file.

overwrite(target, origin_buffer, origin_path)

@spec overwrite(String.t(), pid(), origin_path()) :: t()

Creates an explicit overwrite intent for a captured destination.

validate(save_intent, origin_buffer)

@spec validate(t(), pid()) :: :ok | {:error, :invalid_save_intent}

Validates that an intent has a coherent policy and belongs to the committing buffer.