Crates.io | urn |
lib.rs | urn |
version | 0.7.0 |
source | src |
created_at | 2021-09-22 19:42:53.702066 |
updated_at | 2023-04-08 03:07:31.644579 |
description | A crate for handling URNs (Unique Resource Names) |
homepage | |
repository | https://github.com/chayleaf/urn/ |
max_upload_size | |
id | 455071 |
size | 61,750 |
A Rust crate for handling URNs. Parsing and comparison is done according to the spec (meaning only part of the URN is used for equality checks). Some RFCs define per-namespace lexical equivalence rules, those aren't taken into account here.
RFC2141 is more lenient than RFC8141 at times (and vice versa), care is taken to be able to parse either of them. When percent encoding URN components, the resulting URNs will always be valid for both RFC2141 and RFC8141 parsers. However, percent encoding/decoding rules may be different for some namespaces.
Serde support is available behind a feature flag. no_std
support is
available if you disable the default "std" feature. alloc
is optional
as well. UrnSlice
is a borrowed URN, Urn
is an owned URN. See
docs.rs for documentation.
URNs have a surprising amount of obscure details to the point I'm not sure if other URN parsers can be trusted! Granted, there's very little of them because almost nobody really needs URNs...
FromStr
implUrn::parse
function in favor of FromStr
, improved
docsNamespace
(thanks to
u/chris-morgan for help)Clone
impl for Urn
UrnBuilder::namespace
-> UrnBuilder::nid
alloc
feature, add UrnSlice
type, add percent
module, don't impl Deref<Target = str>
. The crate is getting close
to 1.0.'static
UrnSlice
s,
always encode valid RFC2141 URNs, check for empty string in
percent::encode_*
.TL;DR do whatever you want.
Licensed under either the BSD Zero Clause License (https://opensource.org/licenses/0BSD), the Apache 2.0 License (http://www.apache.org/licenses/LICENSE-2.0) or the MIT License (http://opensource.org/licenses/MIT), at your choice.