Struct iri_string::percent_encode::PercentEncoded
source · [−]pub struct PercentEncoded<T, S> { /* private fields */ }
Expand description
A proxy to percent-encode a string.
Type aliases PercentEncodedForUri
and PercentEncodedForUri
are provided.
You can use them to make the expression simpler, for example write
PercentEncodedForUri::from_path(foo)
instead of
PercentEncoded::<_, UriSpec>::from_path(foo)
.
Implementations
sourceimpl<T: Display, S: Spec> PercentEncoded<T, S>
impl<T: Display, S: Spec> PercentEncoded<T, S>
sourcepub fn from_reg_name(raw: T) -> Self
pub fn from_reg_name(raw: T) -> Self
Creates an encoded string from a raw reg-name (i.e. hostname or domain).
Examples
use iri_string::percent_encode::PercentEncoded;
use iri_string::spec::UriSpec;
let raw = "alpha.\u{03B1}.example.com";
let encoded = "alpha.%CE%B1.example.com";
assert_eq!(
PercentEncoded::<_, UriSpec>::from_reg_name(raw).to_string(),
encoded
);
sourcepub fn from_path_segment(raw: T) -> Self
pub fn from_path_segment(raw: T) -> Self
Creates an encoded string from a raw path segment.
Examples
use iri_string::percent_encode::PercentEncoded;
use iri_string::spec::UriSpec;
let raw = "alpha/\u{03B1}?#";
// Note that `/` is encoded to `%2F`.
let encoded = "alpha%2F%CE%B1%3F%23";
assert_eq!(
PercentEncoded::<_, UriSpec>::from_path_segment(raw).to_string(),
encoded
);
sourcepub fn from_path(raw: T) -> Self
pub fn from_path(raw: T) -> Self
Creates an encoded string from a raw path.
Examples
use iri_string::percent_encode::PercentEncoded;
use iri_string::spec::UriSpec;
let raw = "alpha/\u{03B1}?#";
// Note that `/` is NOT percent encoded.
let encoded = "alpha/%CE%B1%3F%23";
assert_eq!(
PercentEncoded::<_, UriSpec>::from_path(raw).to_string(),
encoded
);
sourcepub fn from_query(raw: T) -> Self
pub fn from_query(raw: T) -> Self
Creates an encoded string from a raw query.
Examples
use iri_string::percent_encode::PercentEncoded;
use iri_string::spec::UriSpec;
let raw = "alpha/\u{03B1}?#";
let encoded = "alpha/%CE%B1?%23";
assert_eq!(
PercentEncoded::<_, UriSpec>::from_query(raw).to_string(),
encoded
);
sourcepub fn from_fragment(raw: T) -> Self
pub fn from_fragment(raw: T) -> Self
Creates an encoded string from a raw fragment.
Examples
use iri_string::percent_encode::PercentEncoded;
use iri_string::spec::UriSpec;
let raw = "alpha/\u{03B1}?#";
let encoded = "alpha/%CE%B1?%23";
assert_eq!(
PercentEncoded::<_, UriSpec>::from_fragment(raw).to_string(),
encoded
);
Trait Implementations
sourceimpl<T: Clone, S: Clone> Clone for PercentEncoded<T, S>
impl<T: Clone, S: Clone> Clone for PercentEncoded<T, S>
sourcefn clone(&self) -> PercentEncoded<T, S>
fn clone(&self) -> PercentEncoded<T, S>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug, S: Debug> Debug for PercentEncoded<T, S>
impl<T: Debug, S: Debug> Debug for PercentEncoded<T, S>
sourceimpl<T: Display, S: Spec> Display for PercentEncoded<T, S>
impl<T: Display, S: Spec> Display for PercentEncoded<T, S>
sourceimpl<T: Display, S: Spec> ProcessAndWrite for &PercentEncoded<T, S>
impl<T: Display, S: Spec> ProcessAndWrite for &PercentEncoded<T, S>
type OutputBorrowed = str
type OutputBorrowed = str
Borrowed output types.
type OutputOwned = String
type OutputOwned = String
Owned output types.
type ProcessError = Infallible
type ProcessError = Infallible
Data processing error.
sourcefn allocate_and_write(
self
) -> Result<Self::OutputOwned, TaskError<Self::ProcessError>>
fn allocate_and_write(
self
) -> Result<Self::OutputOwned, TaskError<Self::ProcessError>>
Processes the data, and writes it to the newly allocated buffer. Read more
sourcefn write_to_byte_slice(
self,
buf: &mut [u8]
) -> Result<&Self::OutputBorrowed, TaskError<Self::ProcessError>>
fn write_to_byte_slice(
self,
buf: &mut [u8]
) -> Result<&Self::OutputBorrowed, TaskError<Self::ProcessError>>
Processes the data, and writes it to the given byte slice. Read more
sourcefn try_append_to_std_string(
self,
buf: &mut String
) -> Result<&Self::OutputBorrowed, TaskError<Self::ProcessError>>
fn try_append_to_std_string(
self,
buf: &mut String
) -> Result<&Self::OutputBorrowed, TaskError<Self::ProcessError>>
sourcefn append_to_std_string(
self,
buf: &mut String
) -> Result<&Self::OutputBorrowed, Self::ProcessError>
fn append_to_std_string(
self,
buf: &mut String
) -> Result<&Self::OutputBorrowed, Self::ProcessError>
impl<T: Copy, S: Copy> Copy for PercentEncoded<T, S>
Auto Trait Implementations
impl<T, S> RefUnwindSafe for PercentEncoded<T, S> where
T: RefUnwindSafe,
impl<T, S> Send for PercentEncoded<T, S> where
T: Send,
impl<T, S> Sync for PercentEncoded<T, S> where
T: Sync,
impl<T, S> Unpin for PercentEncoded<T, S> where
T: Unpin,
impl<T, S> UnwindSafe for PercentEncoded<T, S> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more