Trait StrExt

Source
pub trait StrExt {
    // Required methods
    fn escape_uri(&self) -> EscapeUri<'_, EscapeUriSegment> ;
    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§

Source

fn escape_uri(&self) -> EscapeUri<'_, EscapeUriSegment>

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 are unreserved.
  • for_query(): Escaping appropriate for the query component.
  • for_fragment(): Escaping appropriate for the fragment component.

The returned iterator will escape ASCII control characters.

Source

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:

Source

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().

Implementations on Foreign Types§

Source§

impl StrExt for str

Source§

fn escape_uri(&self) -> EscapeUri<'_, EscapeUriSegment>

Source§

fn unescape_uri(&self) -> UnescapeUri<'_>

Source§

fn unescape_uri_in_place(&mut self) -> &mut str

Implementors§