# `URL.UUID`
[🔗](https://github.com/kipcole9/url/blob/v2.0.3/lib/url/uuid.ex#L1)

Parses the scheme-specific part of a `uuid` URL as described in
[draft-kindel-uuid-uri](https://tools.ietf.org/html/draft-kindel-uuid-uri-00),
and the `urn:uuid:` form of the same identifier.

The primary API is `parse/1`, which `URL.new/1` calls for any
URL with the `uuid` or `urn` scheme. A `urn` whose namespace is
not `uuid` is accepted but yields no parsed path.

# `t`

```elixir
@type t() :: %URL.UUID{params: map(), uuid: binary()}
```

# `parse`

```elixir
@spec parse(URI.t()) :: {:ok, t()} | {:error, {module(), binary()}}
```

Parses the path of a `uuid` or `urn` URI into a `t:t/0` struct.

### Arguments

* `uri` is a `t:URI.t/0` whose `:scheme` is `"uuid"` or `"urn"`.

### Returns

* `{:ok, t:t/0}` with the UUID and any parameters, or

* `{:ok, nil}` for a `urn` whose namespace is not `uuid`, or

* `{:error, {URL.Parser.ParseError, reason}}` if the path is
  not a valid UUID, or the `urn` has no namespace identifier.

### Examples

    iex> uuid = URI.parse("uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6;a=b")
    iex> URL.UUID.parse(uuid)
    {:ok,
     %URL.UUID{uuid: "f81d4fae-7dec-11d0-a765-00a0c91e6bf6", params: %{"a" => "b"}}}

    iex> uuid = URI.parse("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6;a=b")
    iex> URL.UUID.parse(uuid)
    {:ok, %URL.UUID{params: %{"a" => "b"}, uuid: "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"}}

    iex> URL.UUID.parse(URI.parse("urn:isbn:0451450523"))
    {:ok, nil}

    iex> {:error, {URL.Parser.ParseError, _reason}} = URL.UUID.parse(URI.parse("uuid:not-a-uuid"))

---

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