[][src]Struct pct_str::PctString

pub struct PctString { /* fields omitted */ }

Owned, mutable percent-encoded string.

This is the equivalent of String for percent-encoded strings. It implements Deref to PctStr meaning that all methods on PctStr slices are available on PctString values as well.

Implementations

impl PctString[src]

pub fn new<S: AsRef<str> + ?Sized>(str: &S) -> Result<PctString>[src]

Create a new owned percent-encoded string.

The input slice is checked for correct percent-encoding and copied. If the test fails, a InvalidEncoding error is returned.

pub fn encode<I: Iterator<Item = char>, E: Encoder>(
    src: I,
    encoder: E
) -> PctString
[src]

Encode a string into a percent-encoded string.

This function takes an Encoder instance to decide which character of the string must be encoded.

Example

use pct_str::{PctString, URIReserved};

let pct_string = PctString::encode("Hello World!".chars(), URIReserved);
println!("{}", pct_string.as_str()); // => Hello World%21

pub fn as_pct_str(&self) -> &PctStr[src]

Return this string as a borrowed percent-encoded string slice.

pub fn into_string(self) -> String[src]

Return the internal string of the PctString, consuming it

Methods from Deref<Target = PctStr>

pub fn len(&self) -> usize[src]

Length of the string slice, in bytes.

Note that two percent-encoded strings with different lengths may represent the same string.

pub fn as_str(&self) -> &str[src]

Get the underlying percent-encoded string slice.

pub fn chars(&self) -> Chars<'_>

Notable traits for Chars<'a>

impl<'a> Iterator for Chars<'a> type Item = char;
[src]

Iterate over the encoded characters of the string.

pub fn decode(&self) -> String[src]

Decoding.

Return the string with the percent-encoded characters decoded.

Trait Implementations

impl Debug for PctString[src]

impl Deref for PctString[src]

type Target = PctStr

The resulting type after dereferencing.

impl Display for PctString[src]

impl Eq for PctString[src]

impl Hash for PctString[src]

impl<'_> PartialEq<&'_ str> for PctString[src]

impl PartialEq<PctStr> for PctString[src]

impl PartialEq<PctString> for PctStr[src]

impl PartialEq<PctString> for PctString[src]

impl PartialEq<str> for PctString[src]

impl PartialOrd<PctStr> for PctString[src]

impl PartialOrd<PctString> for PctStr[src]

impl PartialOrd<PctString> for PctString[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.