use super::super::UriInner;
use super::super::lazy::LazyUriRef;
use crate::uri::{ParseError, Uri};
pub(super) mod absolute_form;
pub(super) mod accessors;
pub(super) mod adversarial;
pub(super) mod authority_form;
pub(super) mod canonicalize;
pub(super) mod display;
pub(super) mod eq_hash_ord;
pub(super) mod fragment;
pub(super) mod host;
pub(super) mod idna;
pub(super) mod mutation;
pub(super) mod non_http_schemes;
pub(super) mod origin_form;
pub(super) mod path_matcher;
pub(super) mod path_mut;
pub(super) mod path_segments;
pub(super) mod query_collect;
#[cfg(feature = "std")]
pub(super) mod query_deserialize;
pub(super) mod query_mut;
pub(super) mod query_pairs;
pub(super) mod resolve;
pub(super) mod rfc3986_examples;
pub(super) mod serde;
pub(super) mod smoke;
pub(super) mod strict_mode;
pub(super) mod utf8;
pub(super) mod whatwg_corpus;
pub(super) mod wire;
pub(super) fn parse_graceful(s: &str) -> Result<Uri, ParseError> {
Uri::parse(s)
}
pub(super) fn parse_strict(s: &str) -> Result<Uri, ParseError> {
Uri::parse_strict(s)
}
pub(super) fn parse_graceful_bytes(b: &[u8]) -> Result<Uri, ParseError> {
Uri::parse(b)
}
pub(super) fn parse_strict_bytes(b: &[u8]) -> Result<Uri, ParseError> {
Uri::parse_strict(b)
}
pub(super) fn parse_graceful_static(b: &'static [u8]) -> Result<Uri, ParseError> {
Uri::parse(rama_core::bytes::Bytes::from_static(b))
}
pub(super) fn parse_strict_static(b: &'static [u8]) -> Result<Uri, ParseError> {
Uri::parse_strict(rama_core::bytes::Bytes::from_static(b))
}
pub(super) fn lazy(u: &Uri) -> &LazyUriRef {
match &u.inner {
UriInner::Lazy(arc) => arc.as_ref(),
other => panic!("expected Lazy variant, got {other:?}"),
}
}
pub(super) fn range_str(l: &LazyUriRef, r: Option<(u16, u16)>) -> Option<&str> {
r.map(|(s, e)| core::str::from_utf8(&l.bytes[s as usize..e as usize]).unwrap())
}
pub(super) fn path_str(l: &LazyUriRef) -> &str {
core::str::from_utf8(&l.bytes[l.path.0 as usize..l.path.1 as usize]).unwrap()
}
pub(super) fn userinfo_str(l: &LazyUriRef) -> Option<&str> {
let (s, e) = l.authority.as_ref()?.userinfo_range?;
Some(core::str::from_utf8(&l.bytes[s as usize..e as usize]).unwrap())
}
pub(super) fn assert_origin_form(
u: &Uri,
expected_path: &str,
expected_query: Option<&str>,
expected_fragment: Option<&str>,
) {
let l = lazy(u);
assert!(
l.scheme.is_none(),
"scheme: expected None, got {:?}",
l.scheme
);
assert!(
l.authority.is_none(),
"authority: expected None in origin-form"
);
assert_eq!(path_str(l), expected_path, "path");
assert_eq!(range_str(l, l.query), expected_query, "query");
assert_eq!(range_str(l, l.fragment), expected_fragment, "fragment");
}
#[cfg(test)]
const _: fn() = || {
fn assert_send_sync<T: Send + Sync>() {}
use crate::address::{
Authority, AuthorityRef, Host, HostRef, UninterpretedHost, UninterpretedHostRef, UserInfo,
UserInfoRef,
};
#[cfg(feature = "std")]
use crate::uri::QueryDeserializeError;
use crate::uri::{
Fragment, FragmentRef, ParseError, PathCaptures, PathPattern, PathRef, Query, QueryPair,
QueryPairRef, QueryRef, ResolveError, Uri, UriError, WireError,
};
assert_send_sync::<Uri>();
assert_send_sync::<UriError>();
assert_send_sync::<ParseError>();
assert_send_sync::<ResolveError>();
assert_send_sync::<WireError>();
#[cfg(feature = "std")]
assert_send_sync::<QueryDeserializeError>();
assert_send_sync::<Query>();
assert_send_sync::<QueryRef<'static>>();
assert_send_sync::<QueryPair>();
assert_send_sync::<QueryPairRef<'static>>();
assert_send_sync::<Fragment>();
assert_send_sync::<FragmentRef<'static>>();
assert_send_sync::<PathRef<'static>>();
assert_send_sync::<PathPattern>();
assert_send_sync::<PathCaptures<'static, 'static>>();
assert_send_sync::<Authority>();
assert_send_sync::<AuthorityRef<'static>>();
assert_send_sync::<Host>();
assert_send_sync::<HostRef<'static>>();
assert_send_sync::<UserInfo>();
assert_send_sync::<UserInfoRef<'static>>();
assert_send_sync::<UninterpretedHost>();
assert_send_sync::<UninterpretedHostRef<'static>>();
};