# `Macaw.Frame.Document.Limits`
[🔗](https://github.com/dcoai/macaw_frame/blob/v0.1.0/lib/macaw/frame/document/limits.ex#L1)

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.

| Limit | Default | What it bounds |
|---|---|---|
| `ticks` | `1_000` | an axis's tick count |
| `iterations` | `10_000` | a layout's iterations: a force step's `ticks` |
| `counts` | `1_000_000` | every 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}}]

# `name`

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

A limit of this type.

# `counts`

```elixir
@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`

```elixir
@spec defaults() :: %{required(name()) =&gt; pos_integer()}
```

The type's sanity values.

# `new`

```elixir
@spec new(term()) ::
  {:ok, %{required(name()) =&gt; 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}}]}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
