EncodedStr

Struct EncodedStr 

Source
pub struct EncodedStr(/* private fields */);
Expand description

A percent-encoded string.

Implementations§

Source§

impl EncodedStr

Source

pub unsafe fn new_unchecked(s: &[u8]) -> &EncodedStr

Create a new instance of EncodedStr from an encoded str.

§Safety

The given string must be a percent-encoded sequence.

Source

pub fn as_bytes(&self) -> &[u8]

Return the reference to the underling [u8] of this value.

Source

pub fn percent_decode(&self) -> Result<Cow<'_, str>, Utf8Error>

Decode this encoded string as an UTF-8 string.

Source

pub fn percent_decode_lossy(&self) -> Cow<'_, str>

Decode this encoded string as an UTF-8 string.

This method will not fail and the invalid UTF-8 characters will be replaced to � (U+FFFD).

Source

pub fn url_decode(&self) -> Result<Cow<'_, str>, Utf8Error>

Decode this encoded string as an UTF-8 string.

This method will replace the plus (‘+’) character with a half-width space before decoding.

Trait Implementations§

Source§

impl AsRef<[u8]> for EncodedStr

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for EncodedStr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more