use std::marker::PhantomData; use std::borrow::Cow; use percent_encoding::{EncodeSet, utf8_percent_encode}; use uri::{UriPart, Path, Query}; use parse::uri::is_pchar; #[derive(Clone, Copy)] #[allow(non_camel_case_types)] crate struct UNSAFE_ENCODE_SET(PhantomData

); impl Default for UNSAFE_ENCODE_SET

{ #[inline(always)] fn default() -> Self { UNSAFE_ENCODE_SET(PhantomData) } } impl EncodeSet for UNSAFE_ENCODE_SET { #[inline(always)] fn contains(&self, byte: u8) -> bool { !is_pchar(byte) || byte == b'%' } } impl EncodeSet for UNSAFE_ENCODE_SET { #[inline(always)] fn contains(&self, byte: u8) -> bool { (!is_pchar(byte) && (byte != b'?')) || byte == b'%' || byte == b'+' } } #[derive(Clone, Copy)] #[allow(non_camel_case_types)] crate struct ENCODE_SET(PhantomData

); impl EncodeSet for ENCODE_SET { #[inline(always)] fn contains(&self, byte: u8) -> bool { >::default().contains(byte) || byte == b'/' } } impl EncodeSet for ENCODE_SET { #[inline(always)] fn contains(&self, byte: u8) -> bool { >::default().contains(byte) || match byte { b'&' | b'=' => true, _ => false } } } #[derive(Default, Clone, Copy)] #[allow(non_camel_case_types)] crate struct DEFAULT_ENCODE_SET; impl EncodeSet for DEFAULT_ENCODE_SET { #[inline(always)] fn contains(&self, byte: u8) -> bool { ENCODE_SET::(PhantomData).contains(byte) || ENCODE_SET::(PhantomData).contains(byte) } } crate fn unsafe_percent_encode(string: &str) -> Cow { match P::DELIMITER { '/' => percent_encode::>(string), '&' => percent_encode::>(string), _ => percent_encode::(string) } } crate fn percent_encode(string: &str) -> Cow { utf8_percent_encode(string, S::default()).into() }