iri_s/lib.rs
1//! IRI simple wrapper
2//!
3//! This module contains a simple wrapper to work with IRIs
4//! The main goal is that we can use a simple interface to work with IRIs
5//! which could be adapted to different implementations in the future if needed.
6//!
7//! The library provides the macro [`iri`] to create IRIs from strings.
8//!
9// pub mod iri;
10pub mod iris;
11pub mod iris_error;
12
13// pub use iri::*;
14pub use iris::*;
15pub use iris_error::*;
16
17/// ```
18///
19/// #[macro_use]
20/// use iri_s::{IriS, iri};
21///
22/// let iri = iri!("http://example.org/");
23///
24/// assert_eq!(iri.as_str(), "http://example.org/");
25/// ```
26///
27/// At this moment the implementation leverages on [`oxrdf::NamedNode`](https://docs.rs/oxrdf/latest/oxrdf/struct.NamedNode.html)
28///
29///
30///
31/// Example
32///
33/// ```
34/// use iri_s::IriS;
35/// use std::str::FromStr;
36///
37/// let iri = IriS::from_str("http://example.org/").unwrap();
38///
39/// assert_eq!(iri.as_str(), "http://example.org/")
40/// ```
41///
42#[macro_export]
43macro_rules! iri {
44 (
45 $lit: tt
46 ) => {
47 $crate::IriS::new_unchecked($lit)
48 };
49}
50
51#[cfg(test)]
52mod tests {
53 use super::*;
54 use std::str::FromStr;
55
56 #[test]
57 fn iri_s_test() {
58 let iri1: IriS = IriS::from_str("http://example.org/iri").unwrap();
59 let iri2 = IriS::from_str("http://example.org/iri").unwrap();
60 assert_eq!(iri1, iri2);
61 }
62
63 #[test]
64 fn test_macro() {
65 let iri = iri!("http://example.org/");
66 assert_eq!(iri.as_str(), "http://example.org/")
67 }
68}