pub trait StrExt {
// Required methods
fn escape_uri(&self) -> EscapeUri<'_> ⓘ;
fn unescape_uri(&self) -> UnescapeUri<'_> ⓘ;
fn unescape_uri_in_place(&mut self) -> &mut str;
}Expand description
Trait for str adding URI percent encoding/decoding
See the module-level documentation for more details.
Required Methods§
Sourcefn escape_uri(&self) -> EscapeUri<'_> ⓘ
fn escape_uri(&self) -> EscapeUri<'_> ⓘ
Gets an iterator that performs general-purpose URI percent-encoding.
By default, all characters described by [IETF-RFC3986] as pchars will be escaped,
which is appropriate for escaping path segments.
This behavior can be modified by appending the following modifiers:
full(): Escapes all characters except those which areunreserved.for_query(): Escaping appropriate for the query component.for_fragment(): Escaping appropriate for the fragment component.
The returned iterator will escape ASCII control characters.
Sourcefn unescape_uri(&self) -> UnescapeUri<'_> ⓘ
fn unescape_uri(&self) -> UnescapeUri<'_> ⓘ
Gets an iterator that performs URI percent-decoding.
By default, when the iterator encounters an error the behavior is as follows:
- Unescaped ASCII control codes are dropped.
- Escaped ASCII control codes are converted to Unicode Control Pictures (i.e.
%00=>␀) - Bad percent-escape sequences (like
"%Foo") are replaced withU+FFFD REPLACEMENT CHARACTER - Incomplete UTF8 sequences (like
"%E2%82") are replaced withU+FFFD REPLACEMENT CHARACTER - Invalid UTF8 sequences (like
"%E2%82%E2") are replaced withU+FFFD REPLACEMENT CHARACTER
Sourcefn unescape_uri_in_place(&mut self) -> &mut str
fn unescape_uri_in_place(&mut self) -> &mut str
Experimental: Unescapes the given mutable string in-place, returning a subset of the mutable slice even if it contains encoding errors or illegal characters.
The behavior upon encountering errors is identical to that of
unescape_uri().