Skip to main content

HttpUriExt

Trait HttpUriExt 

Source
pub trait HttpUriExt {
    // Required methods
    fn extend_dir_with_path(self, path: &str) -> Result<Uri, Error>;
    fn append_query_parameter(
        self,
        key: &str,
        value: &str,
    ) -> Result<Uri, Error>;
    fn join(&self, relative: &str) -> Result<Uri, Error>;
}

Required Methods§

Source

fn extend_dir_with_path(self, path: &str) -> Result<Uri, Error>

Appends / to self’s path if it does not already end with one, then appends path, preserving any query parameters. Does nothing if path is the empty string. Note that empty paths on URIs with authorities are implicitly normalized to start with / by http::Uri.

Will error if path contains invalid URI characters, or if the resulting URI parts are invalid (e.g., combining an authority and path without a scheme).

Source

fn append_query_parameter(self, key: &str, value: &str) -> Result<Uri, Error>

Append the given query parameter key=value to the URI, preserving existing query parameters if any, key and value should already be URL-encoded (if necessary).

Will only error if key or value contains invalid URI characters.

Source

fn join(&self, relative: &str) -> Result<Uri, Error>

Joins a relative URI or path to this base URI. Similar to url::Url::join but for http::Uri.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl HttpUriExt for Uri

Source§

fn extend_dir_with_path(self, path: &str) -> Result<Uri, Error>

Source§

fn append_query_parameter(self, key: &str, value: &str) -> Result<Uri, Error>

Source§

fn join(&self, relative: &str) -> Result<Uri, Error>

Implementors§