#iri #uri #specification #parser #fork #temporary #rdftk

field33_rdftk_iri_temporary_fork

This crate provides an implementation of the IRI and URI specifications

1 unstable release

0.1.9 Aug 23, 2022

#11 in #iri

Download history 26/week @ 2024-08-26 9/week @ 2024-09-02 13/week @ 2024-09-09 9/week @ 2024-09-16 36/week @ 2024-09-23 14/week @ 2024-09-30 1/week @ 2024-10-07 14/week @ 2024-10-14 9/week @ 2024-10-21 14/week @ 2024-10-28 15/week @ 2024-11-04 15/week @ 2024-11-18 19/week @ 2024-11-25 26/week @ 2024-12-02 51/week @ 2024-12-09

111 downloads per month
Used in 7 crates (6 directly)

MIT license

140KB
2K SLoC

Rust 2K SLoC // 0.2% comments Pest 261 SLoC // 0.4% comments

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 field33_rdftk_iri_temporary_fork::IRI;
use std::convert::from_str;

let result = IRI::from_str(
    "https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top",
);

The builder module allows for more programmatic construction of IRIs.

use field33_rdftk_iri_temporary_fork::{IRI, Scheme};
use field33_rdftk_iri_temporary_fork::builder::IriBuilder;

let mut builder = IriBuilder::default();
let result: IriResult<IRI> = builder
    .scheme(&Scheme::https())
    .user_name("john.doe")
    .host("www.example.com")?
    .port(123.into())
    .path_str("/forum/questions/")?
    .query_str("tag=networking&order=newest")?
    .fragment_str("top")?
    .try_into();

Note also the use of Scheme::https(), both the Scheme and Port types include associated functions to construct well-known values.

Features

The following features are present in this crate.

  • builder [default] -- include the builder module, which in turn includes the IriBuilder type.
  • genid [default] -- includes a constructor to create "genid" well-known IRI values.
  • path_iri [default] -- provides an implementation of TryFrom<&PathBuf> and TryFrom<PathBuf> for IRI.
  • uuid_iri [default] -- provides an implementation of TryFrom<&Uuid> and TryFrom<Uuid> for IRI.

Changes

Version 0.1.9

  • Added a feature to enable genid creation.
  • Made IRI PartialOrd + Ord, it can now be sorted.
  • Added PercentEncoding trait for percent encoding components.

Version 0.1.8

  • Minor fix to parser to fix some precedence rules.
  • Some documentation fixes.

Version 0.1.7

  • Added support for well-known IRIs to the Path and IRI types.

Version 0.1.6

  • Applied a lot more warnings in lib.rs
  • Applied more Clippy suggestions.

Version 0.1.5

  • Applied all Clippy suggestions.

Version 0.1.4

  • A lot more testing, and local coverage reporting.
  • Fixed a bug where separator missing in UserInfo::to_string.
  • Fixed a parsing bug IpvFuture::from_str.
  • Added host, path_root, path methods to IriBuilder.
  • Changes with_new_query and with_new_fragment on IRI to not take Option.
  • Added blob known value to Scheme.

Version 0.1.3

  • Mostly testing
    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.
  • Fixed bug in IRI::is_absolute, to ignore authority and take the fragment into account.
  • Added IRI::is_relative_reference.

Version 0.1.2

  • Mostly documentation additions.
  • Adding test cases where possible.
  • Added helper functions and API shortcuts where they make sense.
  • Added path_iri and uuid_iri features.

Version 0.1.1

  • Added IRIRef type.

Version 0.1.0

  • First release.

TODO

  1. Complete IRI normalization
  2. Complete IRI resolver
  3. Complete IRI relativizer

RDF

Dependencies

~5–11MB
~129K SLoC