# `CRAM.Reference`
[🔗](https://github.com/baoulo/cram-elixir/blob/v0.1.0/lib/cram/reference.ex#L1)

Explicit reference lookup.

Passing a provider to `CRAM.open/2` stores it on the handle. Container
inspection does not call `fetch/3`.

# `fetch`

```elixir
@spec fetch(term(), String.t(), String.t() | nil) ::
  {:ok, binary()} | {:error, CRAM.Error.t()}
```

Fetch `name` from `provider` and check `expected_md5`.

`provider` is a struct whose module implements `CRAM.ReferenceProvider`.
`name` is a binary. `expected_md5` is a hex string or `nil`.

Returns `{:ok, bases}` or `{:error, %CRAM.Error{}}`. A value that is not a
struct is `reason: :reference_missing` and does not raise. The provider's
own errors pass through unchanged.

    iex> {:ok, local} = CRAM.Reference.Local.new("tutorials/fixtures/sq0.fa")
    iex> CRAM.Reference.fetch(local, "sq0", "be19336b7e15968f7ac7dc82493d9cd8")
    {:ok, "TTCACCCA"}
    iex> {:error, error} = CRAM.Reference.fetch(:nope, "sq0", nil)
    iex> error.reason
    :reference_missing

---

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