Skip to main content

Crate curieosa

Crate curieosa 

Source
Expand description

§curieosa

crates.io https://github.com/ielis/curieosa/actions/workflows/ci.yml

A crate for parsing Internationalized Resource Identifiers (IRIs) into Compact Uniform Resource Identifiers (CURIEs).

Add the following into your Cargo.toml file to use curieosa in your code:

curieosa = "0.1.1"

CREDIT

curieosa is heavily inspired by the curie-util library written by Chris Mungall in Java. This Rust port is intentionally very similar to the Java library, to simplify its usage.

§Examples

Get an implementation of CurieUtil backed by a trie with default prefix -> expansion mappings.

use curieosa::{TrieCurieUtil, CurieUtil, CurieParts};

let cu = TrieCurieUtil::default();

// Get curie parts from an IRI
let iri = "http://purl.obolibrary.org/obo/HP_0001250";
let cp: CurieParts<'_, '_> = cu.get_curie_data(iri).unwrap();

assert_eq!(cp.get_prefix(), "HP");
assert_eq!(cp.get_id(), "0001250");

§Run tests

Run all tests by running:

cargo test

§Run benches

We use criterion to benchmark IRI parsing.

Run the following to run the bench suite:

cargo bench

Structs§

CurieParts
A simple POD with references to a CURIE prefix that lives either as long as Curie Util or as the IRI, and to a CURIE id that lives as long as the IRI.
TrieCurieUtil
A CurieUtil implementation backed by a trie.

Enums§

CuriePrefix
An enum pointing to the CURIE prefix source.

Traits§

CurieUtil
CurieUtil can expand prefix into an expansion, check if a prefix can be expanded, and find CURIE subparts in an IRI.