Skip to main content

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: &(impl AsRef<[u8]> + ?Sized)) -> &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
Source§

impl<'a, 'b> PartialEq<&'b EncodedStr> for &'a EncodedStr

Source§

fn eq(&self, other: &&'b EncodedStr) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<String> for EncodedStr

Source§

fn eq(&self, other: &String) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> PartialEq<String> for &'a EncodedStr

Source§

fn eq(&self, other: &String) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<str> for EncodedStr

Source§

fn eq(&self, other: &str) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> PartialEq<str> for &'a EncodedStr

Source§

fn eq(&self, other: &str) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. 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