Macaw.Frame.Document.Limits (macaw_frame v0.1.0)

Copy Markdown View Source

The frame document's own limits (spec/02 §9.2): what rendering a design read from elsewhere can be made to cost, checked over the migrated value.

LimitDefaultWhat it bounds
ticks1_000an axis's tick count
iterations10_000a layout's iterations: a force step's ticks
counts1_000_000every other count a step reads: thresholds, samples, n, width, a grid's dimensions

A host tightens a limit with a plain value, or raises one only by naming the raise, {:raise, max}, through limits: as the kernel's (Macaw.Layers.Limits) are; the kernel's bytes, depth and items are its own. A value over a limit is {path, {:limit, name, max, given}}. A variable is not a literal and is not checked.

iex> design = %{frames: %{"main" => %{kind: "cartesian", axes: [%{scale: "x", side: :bottom, ticks: 5000}]}}}
iex> Macaw.Frame.Document.Limits.counts(design, [])
[{[:frames, "main", :axes, 0, :ticks], {:limit, :ticks, 1000, 5000}}]

Summary

Types

A limit of this type.

Functions

Every count of a design over its limit, by path (§9.2): limits as new/1 takes them, or the limits it answers. A limits that does not read answers its own faults under [:limits].

The type's sanity values.

The limits a reader applies, given over defaults/0: {:ok, limits}, or every fault by name. The kernel's own names are left to it; any other name is :unknown_key, a value neither a positive integer nor {:raise, max} is {:limit_value, default}, a plain value above the default {:limit_loosened, default} and a raise not above it {:limit_not_raised, default}.

Types

name()

@type name() :: :ticks | :iterations | :counts

A limit of this type.

Functions

counts(design, limits)

@spec counts(term(), term()) :: [Macaw.Base.Fault.t()]

Every count of a design over its limit, by path (§9.2): limits as new/1 takes them, or the limits it answers. A limits that does not read answers its own faults under [:limits].

defaults()

@spec defaults() :: %{required(name()) => pos_integer()}

The type's sanity values.

new(given)

@spec new(term()) ::
  {:ok, %{required(name()) => pos_integer()}}
  | {:error, [Macaw.Base.Fault.t(), ...]}

The limits a reader applies, given over defaults/0: {:ok, limits}, or every fault by name. The kernel's own names are left to it; any other name is :unknown_key, a value neither a positive integer nor {:raise, max} is {:limit_value, default}, a plain value above the default {:limit_loosened, default} and a raise not above it {:limit_not_raised, default}.

iex> Macaw.Frame.Document.Limits.new(ticks: 100, bytes: 10)
{:ok, %{ticks: 100, iterations: 10_000, counts: 1_000_000}}
iex> Macaw.Frame.Document.Limits.new(ticks: 5_000)
{:error, [{[:ticks], {:limit_loosened, 1000}}]}