1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
use crate::spec::UriSpec;
use crate::types::{
IriAbsoluteStr, IriFragmentStr, IriQueryStr, IriReferenceStr, IriRelativeStr, IriStr,
RiAbsoluteStr, RiFragmentStr, RiQueryStr, RiReferenceStr, RiRelativeStr, RiStr,
};
#[cfg(feature = "alloc")]
use crate::types::{
IriAbsoluteString, IriFragmentString, IriQueryString, IriReferenceString, IriRelativeString,
IriString, RiAbsoluteString, RiFragmentString, RiQueryString, RiReferenceString,
RiRelativeString, RiString,
};
pub type UriAbsoluteStr = RiAbsoluteStr<UriSpec>;
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub type UriAbsoluteString = RiAbsoluteString<UriSpec>;
pub type UriFragmentStr = RiFragmentStr<UriSpec>;
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub type UriFragmentString = RiFragmentString<UriSpec>;
pub type UriStr = RiStr<UriSpec>;
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub type UriString = RiString<UriSpec>;
pub type UriReferenceStr = RiReferenceStr<UriSpec>;
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub type UriReferenceString = RiReferenceString<UriSpec>;
pub type UriRelativeStr = RiRelativeStr<UriSpec>;
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub type UriRelativeString = RiRelativeString<UriSpec>;
pub type UriQueryStr = RiQueryStr<UriSpec>;
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub type UriQueryString = RiQueryString<UriSpec>;
macro_rules! impl_conversions_between_iri {
(
$borrowed_uri:ident,
$owned_uri:ident,
$borrowed_iri:ident,
$owned_iri:ident,
) => {
impl AsRef<$borrowed_iri> for $borrowed_uri {
fn as_ref(&self) -> &$borrowed_iri {
unsafe {
<$borrowed_iri>::new_maybe_unchecked(self.as_str())
}
}
}
#[cfg(feature = "alloc")]
impl From<$owned_uri> for $owned_iri {
#[inline]
fn from(uri: $owned_uri) -> Self {
unsafe {
Self::new_maybe_unchecked(uri.into())
}
}
}
#[cfg(feature = "alloc")]
impl AsRef<$borrowed_iri> for $owned_uri {
fn as_ref(&self) -> &$borrowed_iri {
AsRef::<$borrowed_uri>::as_ref(self).as_ref()
}
}
};
}
impl_conversions_between_iri!(
UriAbsoluteStr,
UriAbsoluteString,
IriAbsoluteStr,
IriAbsoluteString,
);
impl_conversions_between_iri!(
UriReferenceStr,
UriReferenceString,
IriReferenceStr,
IriReferenceString,
);
impl_conversions_between_iri!(
UriRelativeStr,
UriRelativeString,
IriRelativeStr,
IriRelativeString,
);
impl_conversions_between_iri!(UriStr, UriString, IriStr, IriString,);
impl_conversions_between_iri!(UriQueryStr, UriQueryString, IriQueryStr, IriQueryString,);
impl_conversions_between_iri!(
UriFragmentStr,
UriFragmentString,
IriFragmentStr,
IriFragmentString,
);