# `BAM.Limits`
[🔗](https://github.com/baoulo/bam-elixir/blob/v0.1.0/lib/bam/limits.ex#L1)

Caps applied while decoding untrusted BAM, BGZF, and index bytes.

Each field is a maximum this library will accept before it returns
`{:error, %BAM.Error{category: :resource_limit}}`. BGZF uncompressed
size is also hard-capped at 65_536 by the SAM specification. That cap
is not configurable.

Defaults are large enough for current reference genomes and long reads,
and small enough that a hostile length field cannot force an unbounded
allocation.

# `t`

```elixir
@type t() :: %BAM.Limits{
  max_aux_array: pos_integer(),
  max_aux_bytes: pos_integer(),
  max_bins: pos_integer(),
  max_chunks: pos_integer(),
  max_cigar_ops: pos_integer(),
  max_header_bytes: pos_integer(),
  max_index_bytes: pos_integer(),
  max_linear_index: pos_integer(),
  max_read_name_bytes: pos_integer(),
  max_record_bytes: pos_integer(),
  max_records: pos_integer() | nil,
  max_reference_name_bytes: pos_integer(),
  max_references: pos_integer()
}
```

# `default`

```elixir
@spec default() :: t()
```

Default caps.

# `merge`

```elixir
@spec merge(keyword() | map() | t()) :: {:ok, t()} | {:error, BAM.Error.t()}
```

Merges a keyword or map of overrides onto the defaults.

Unknown keys are an invalid argument. Values must be positive integers,
except `:max_records`, which may be `nil`.

---

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