pub struct HttpUri<'uri> { /* private fields */ }
Expand description

A type representing valid http uri

Implementations

make it’s lifetime static

Normalizes inner uri per rfc

Checks If explicit port of http uri is same as corresponding default port of it’s http(s) scheme,

Removes explicit port, if explicit port of http uri is same as corresponding default port of it’s http(s) scheme, Otherwise, this method is no op.

Removes non-trailing empty segments.

Methods from Deref<Target = URI<'uri>>

Returns the authority, if present, of the URI.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://example.com:80/my/path").unwrap();
assert_eq!(uri.authority().unwrap().to_string(), "example.com:80");

Returns whether the URI can act as a base URI.

A URI can be a base if it is absolute (i.e. it has no fragment component).

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://example.com/my/path").unwrap();
assert!(uri.can_be_a_base());

let uri = URI::try_from("ftp://127.0.0.1#fragment").unwrap();
assert!(!uri.can_be_a_base());

Returns the fragment, if present, of the URI.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://example.com#fragment").unwrap();
assert_eq!(uri.fragment().unwrap(), "fragment");

Returns whether the URI has an authority component.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://example.com").unwrap();
assert!(uri.has_authority());

let uri = URI::try_from("urn:test").unwrap();
assert!(!uri.has_authority());

Returns whether the URI has a fragment component.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://example.com#test").unwrap();
assert!(uri.has_fragment());

let uri = URI::try_from("http://example.com").unwrap();
assert!(!uri.has_fragment());

Returns whether the URI has a password component.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://user:pass@127.0.0.1").unwrap();
assert!(uri.has_password());

let uri = URI::try_from("http://user@127.0.0.1").unwrap();
assert!(!uri.has_password());

Returns whether the URI has a port.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://127.0.0.1:8080").unwrap();
assert!(uri.has_port());

let uri = URI::try_from("http://127.0.0.1").unwrap();
assert!(!uri.has_port());

Returns whether the URI has a query component.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://example.com/my/path?my=query").unwrap();
assert!(uri.has_query());

let uri = URI::try_from("http://example.com/my/path").unwrap();
assert!(!uri.has_query());

Returns whether the URI has a username component.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://username@example.com").unwrap();
assert!(uri.has_username());

let uri = URI::try_from("http://example.com").unwrap();
assert!(!uri.has_username());

Returns the host, if present, of the URI.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://username@example.com").unwrap();
assert_eq!(uri.host().unwrap().to_string(), "example.com");

Returns whether the URI is normalized.

A normalized URI will have all of its components normalized.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://example.com/?a=b").unwrap();
assert!(uri.is_normalized());

let mut uri = URI::try_from("http://EXAMPLE.com/?a=b").unwrap();
assert!(!uri.is_normalized());
uri.normalize();
assert!(uri.is_normalized());

Returns the path of the URI.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://127.0.0.1/my/path").unwrap();
assert_eq!(uri.path(), "/my/path");

Returns the password, if present, of the URI.

Usage of a password in URIs is deprecated.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://user:pass@example.com").unwrap();
assert_eq!(uri.password().unwrap(), "pass");

Returns the port, if present, of the URI.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://example.com:8080/").unwrap();
assert_eq!(uri.port().unwrap(), 8080);

Returns the query, if present, of the URI.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://127.0.0.1?my=query").unwrap();
assert_eq!(uri.query().unwrap(), "my=query");

Creates a new URI which is created by resolving the given reference against this URI.

The algorithm used for resolving the reference is described in [RFC3986, Section 5.2.2].

Returns the scheme of the URI.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://127.0.0.1/").unwrap();
assert_eq!(uri.scheme(), "http");

Returns a new URI which is identical but has a lifetime tied to this URI.

This function will perform a memory allocation.

Returns the username, if present, of the URI.

Examples
use std::convert::TryFrom;

use uriparse::URI;

let uri = URI::try_from("http://username@example.com").unwrap();
assert_eq!(uri.username().unwrap(), "username");

Trait Implementations

Performs the conversion.

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

Implementation in parity with remaining other invariants

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.

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.

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.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. 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.