#iri #uri #string #parser #rdf #specification #data

rdftk_iri

This crate provides an implementation of the IRI and URI specifications

15 releases

0.2.5 Oct 8, 2024
0.2.3 Sep 11, 2024
0.1.9 Jun 8, 2021
0.1.4 Nov 2, 2020
0.1.0 Jul 28, 2020

#486 in Web programming

Download history 23/week @ 2024-08-19 68/week @ 2024-08-26 429/week @ 2024-09-02 142/week @ 2024-09-09 121/week @ 2024-09-16 82/week @ 2024-09-23 177/week @ 2024-09-30 221/week @ 2024-10-07 483/week @ 2024-10-14 53/week @ 2024-10-21 5/week @ 2024-10-28 10/week @ 2024-11-04 46/week @ 2024-11-11 22/week @ 2024-11-18 25/week @ 2024-11-25 22/week @ 2024-12-02

115 downloads per month
Used in 15 crates (11 directly)

MIT license

40KB
403 lines

RDFtk: IRI

iri This crate provides an implementation of the IRI and URI specifications.

crates.io docs.rs

As with the rest of the RDFtk project the aim of this crate is usability over optimization, and so it may perform more clones than necessary and parse more slowly than could be the case. For the most part clients should use the IriRef type that is an Arc reference and so can be reused without cloning the whole Iri value.

Example

The most common use is the parsing of an IRI value from a string.

use rdftk_iri::{Iri, IriExtra as _};
use std::str::FromStr;

let namespace = Iri::from_str(
    "https://example.org/ns/things#",
).unwrap();
assert!(namespace.looks_like_namespace());

let name = namespace.make_name("ThisThing").unwrap();
assert_eq!(
    name.to_string(),
    "https://example.org/ns/things#ThisThing".to_string(),
);

assert_eq!(
    name.namespace(),
    Some(namespace),
);

assert_eq!(
    name.name(),
    Some("ThisThing".to_string()),
);

Changes

Version 0.2.5

  • Feature: added From<QName and From<&QName> for String.

Version 0.2.4

  • Refactor: move the QName type into this package from core.

Version 0.2.3

  • Feature: added From<&Name> for String.

Version 0.2.2

  • Feature: added new Name structure (and NameParseError) to validate the name component of an IRI representing a namespaced-name.
    • Added type NameParser to encapsulate different name rules.
    • Added type NameParseError for errors generated by name parsers.
    • Altered return types of IriExtra::split and IriExtra::name.
    • Altered parameter type in IriExtra::make_name.

Version 0.2.1

  • Build: cargo audit/outdated/udeps

Version 0.2.0

  • Refactor: replaced own implementation of IRI with the url crate.
    • Added trait IriExtra to provide new methods to the url::Url type.
    • Added doc comments/tests for IriExtra.
  • Build: updated Rust edition from 2018 to 2021.
  • Docs: run markuplint on README.md.

Version 0.1.9

  • Feature: added a feature to enable genid creation.
  • Feature: made IRI implement PartialOrd + Ord, it can now be sorted.
  • Feature: added PercentEncoding trait for percent encoding components.

Version 0.1.8

  • Fix: parser to fix some precedence rules.
  • Docs: some documentation fixes.

Version 0.1.7

  • Feature: added support for well-known IRIs to the Path and IRI types.

Version 0.1.6

  • Style: applied a lot more warnings in lib.rs
  • Style: applied more Clippy suggestions.

Version 0.1.5

  • Style: applied all Clippy suggestions.

Version 0.1.4

  • Test: more testing, and local coverage reporting.
  • Fix: bug where separator missing in UserInfo::to_string.
  • Fix: parsing bug IpvFuture::from_str.
  • Feature: added host, path_root, path methods to IriBuilder.
  • Feature: ahanges with_new_query and with_new_fragment on IRI to not take Option.
  • Feature: added blob known value to Scheme.

Version 0.1.3

  • Test:
    1. Moved any tests out of the main code if they only use the public API.
    2. Added a set of files for gathering whole IRI examples.
    3. Added proptest for Scheme, will add for more.
  • Fix: bug in IRI::is_absolute, to ignore authority and take the fragment into account.
  • Feature: added IRI::is_relative_reference.

Version 0.1.2

  • Doc: mostly documentation additions.
  • Test: adding test cases where possible.
  • Feature: added helper functions and API shortcuts where they make sense.
  • Feature: added path_iri and uuid_iri features.

Version 0.1.1

  • Feature: added IRIRef type.

Version 0.1.0

  • First release.

Dependencies

~2.3–3.5MB
~59K SLoC