A Rust crate for handling URNs.

Related tags

Utilities urn
Overview

crates.io docs.rs

URN

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. no_std support is available if you disable the default "std" feature. alloc is needed, but the Urn type is a wrapper around String and should only use a single allocation (but I haven't checked). You can even construct a Urn from your own String by using TryFrom , that way it shouldn't allocate at all.

URNs have a surprising amount of obscure details to the point I'm not sure at this point if other URN parsers can be trusted! Granted, there's very little of them because almost nobody really needs URNs...

Changelog

  • 0.1.0 - initial release
  • 0.1.1 - add FromStr impl
  • 0.2.0 - remove Urn::parse function in favor of FromStr, improve docs
  • 0.2.1 - remove files left over from 0.1
  • 0.3.0 - major implementation changes, remove Namespace (thanks to u/chris-morgan for help)
  • 0.3.1 - fix a panic on empty NSS and add ?= terminator to r-component (both ? and = can be part of r-component, but together they terminate it)
  • 0.3.2 - add Clone impl for Urn
  • 0.3.3 - more precise builder errors; reduce memory footprint by up to 15 bytes (but increase it by 5 bytes on 16-bit platforms)

License

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.

You might also like...
This crate allows you to safely initialize Dynamically Sized Types (DST) using only safe Rust.

This crate allows you to safely initialize Dynamically Sized Types (DST) using only safe Rust.

An experimental Rust crate for sigstore

Continuous integration Docs License This is an experimental crate to interact with sigstore. This is under high development, many features and checks

Rust crate that provides a convenient macro to quickly plot variables.
Rust crate that provides a convenient macro to quickly plot variables.

Debug Plotter This crate provides a convenient macro to quickly plot variables. Documentation For more information on how to use this crate, please ta

Rust crate for making Read streams peekable.

peekread This crate allows you to take an arbitrary Read stream and 'peek ahead' into the stream without consuming the original stream. This is done t

Rust Hardware Abstraction Layer (HAL) crate for the Vorago VA108xx family of MCUs

HAL for the Vorago VA108xx MCU family This repository contains the Hardware Abstraction Layer (HAL), which is an additional hardware abstraction on to

IDX is a Rust crate for working with RuneScape .idx-format caches.
IDX is a Rust crate for working with RuneScape .idx-format caches.

This image proudly made in GIMP License Licensed under GNU GPL, Version 3.0, (LICENSE-GPL3 or https://choosealicense.com/licenses/gpl-3.0/) Contributi

Board Support Crate for Arduino Leonardo in Rust

Deprecation Note: This crate will soon be deprecated in favor of avr-hal. avr-hal is a new approach to writing the HAL crate, that was designed with s

A Rust crate that provides a simple interface for LZMA compression and decompression.

rust-lzma Documentation This crate provides a simple interface to liblzma. LZMA is more commonly known as XZ or 7zip, (as in, files with the .xz or .7

Rust crate for creating filters with DirectX shaders. Includes Scale, Color conversion using DirectX api.

DxFilter Scale and ColorConversion done with DirectX filters. You can also create your own filters with the provided api. Crate contains various tools

Comments
  • more accurate builder errors

    more accurate builder errors

    Currently, the URN gets created as-is, and build() returns whatever error there is if it fails. For example, setting abc:: as the namespace (and hence making the URN start with urn:abc::) will make it fail with InvalidNss despite it actually being an invalid namespace. I'm not interested in this enough to fix it at the moment, but maybe I'll do it some day.

    bug 
    opened by chayleaf 1
  • URN::parse panics on UTF strings

    URN::parse panics on UTF strings

    Description

    URN::parse panics when it tries to lowercase a UTF string. I am aware that the RFC specifies only ASCII characters but it should return Err instead.

    My current workaround is to check with str::is_ascii before parsing.

    assert!("6򭞦*c!󈰠v #ž®􇣺[®nE⁐‹c;gPS5<5!¡r󠀁R⁎".parse::<Urn>().is_ok());
    
    thread 'tests::custom_test' panicked at 'byte index 4 is not a char boundary; it is inside '\u{ad7a6}' (bytes 1..5) of `6򭞦*c!󈰠v #ž®􇣺[®nE⁐‹c;gPS5<5!¡r󠀁R⁎`', src/lib.rs:76:21
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    opened by FrancisMurillo 0
Owner
null
Open-source NI maschine device handling

Open-source NI maschine device handling

william light 69 Dec 1, 2022
A simple program for handling Ethiopian calendar dates.

Mek’ut’erīya A simple program for handling Ethiopian calendar dates. Installation cargo install --git https://github.com/frectonz/mek-ut-er-ya If you

Fraol Lemecha 15 Dec 20, 2022
Rust crate which provides direct access to files within a Debian archive

debarchive This Rust crate provides direct access to files within a Debian archive. This crate is used by our debrep utility to generate the Packages

Pop!_OS 11 Dec 18, 2021
Granular locking crate for Rust

Granular locking crate for Rust. Instead of using coarse-grained Mutex or RwLock which can be used to lock an entire structure, glock provides more granular locking.

Ayman Madkour 9 Jul 22, 2022
A crate to implement leader election for Kubernetes workloads in Rust.

Kubernetes Leader Election in Rust This library provides simple leader election for Kubernetes workloads.

Hendrik Maus 33 Dec 29, 2022
This crate allows writing a struct in Rust and have it derive a struct of arrays layed out in memory according to the arrow format.

Arrow2-derive - derive for Arrow2 This crate allows writing a struct in Rust and have it derive a struct of arrays layed out in memory according to th

Jorge Leitao 29 Dec 27, 2022
Tiny Rust crate to iterate bit combinations

bit_combi_iter bit_combi_iter is a small dependency-free crate to enumerate all bit combinations less than given unsigned integer value keeping 1s in

Linda_pp 5 Apr 11, 2022
Membrane is an opinionated crate that generates a Dart package from a Rust library. Extremely fast performance with strict typing and zero copy returns over the FFI boundary via bincode.

Membrane is an opinionated crate that generates a Dart package from a Rust library. Extremely fast performance with strict typing and zero copy returns over the FFI boundary via bincode.

Jerel Unruh 70 Dec 13, 2022
Rust crate for reading SER files used in astrophotography

Rust crate for reading SER files used in astrophotography.

Andy Grove 2 Oct 4, 2021
The efficient and elegant crate to count variants of Rust's Enum.

variant-counter The efficient and elegant crate to count variants of Rust's Enum. Get started #[derive(VariantCount)] #[derive(VariantCount)] pub enum

Folyd 16 Sep 29, 2022