Reference

std/uri/urn

std/uri/src/urn.trb

Urn: a urn: URI read into the parts RFC 8141 gives it - a namespace identifier, a namespace-specific string, and the r-, q- and f-components (docs/design/URI.md section 7).

type Urn

type Urn with Show, Equals, Hash, Compare

A URN per RFC 8141: urn:<namespace>:<specific>, with the namespace identifier lower case and everything else as the Uri it was read from normalized it.

== is over the whole URN. RFC 8141 section 3's equivalence ignores the r-, q- and f-components, and it is Urn.assignedName compared: first.assignedName() == second.assignedName().

Examples

const uri: Uri = "urn:UUID:f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
const name = Urn.tryFrom(uri)?
print "{name.namespace()} {name.specific()}"

fn uri

fn uri(): Uri

The URI this name is.

fn namespace

fn namespace(): String

The namespace identifier, lower case: uuid in urn:uuid:….

fn specific

fn specific(): String

The namespace-specific string: everything after the second :, up to the r-, q- or f-component.

fn resolution

fn resolution(): String?

The r-component: what follows ?+, a request to a resolver.

fn query

fn query(): String?

The q-component: what follows ?=, a query for the named resource.

fn fragment

fn fragment(): String?

The f-component: what follows #.

fn assignedName

fn assignedName(): Urn

The URN without its r-, q- and f-components: what RFC 8141 section 3 compares.

fn show

fn show(): String

The URN as its URI shows it.

fn compare

fn compare(other: Urn): Ordering

In the order of the URIs.

extend Urn with TryFrom<Uri, UriError>

extend Urn with TryFrom<Uri, UriError>

A URI read as a URN (RFC 8141 section 2): no authority, a namespace identifier of two to thirty-two letters, digits and - that neither starts nor ends with a -, a :, a namespace-specific string that is not empty and does not start with /, and a query that is an r-component, a q-component or both.

Errors

fn tryFrom

static fn tryFrom(value: Uri): Result<Urn, UriError>

extend Uri with From<Urn>

extend Uri with From<Urn>

The URI a URN is.

fn from

static fn from(value: Urn): Uri