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

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
);

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
);

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
);

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
);

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Borrowed output types.

Owned output types.

Data processing error.

Processes the data, and writes it to the newly allocated buffer. Read more

Processes the data, and writes it to the given byte slice. Read more

Processes the data, and appends it to the buffer inside the provided String. Read more

Processes the data, and appends it to the buffer inside the provided String. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.