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