[][src]Struct http_req::uri::Uri

pub struct Uri { /* fields omitted */ }

Representation of Uniform Resource Identifier

Example

use http_req::uri::Uri;

let uri: Uri = "https://user:info@foo.com:12/bar/baz?query#fragment".parse().unwrap();
assert_eq!(uri.host(), Some("foo.com"));

Methods

impl Uri[src]

pub fn scheme(&self) -> &str[src]

Returns scheme of this Uri.

Example

use http_req::uri::Uri;

let uri: Uri = "https://user:info@foo.com:12/bar/baz?query#fragment".parse().unwrap();
assert_eq!(uri.scheme(), "https");

pub fn user_info(&self) -> Option<&str>[src]

Returns information about the user included in this Uri.

Example

use http_req::uri::Uri;

let uri: Uri = "https://user:info@foo.com:12/bar/baz?query#fragment".parse().unwrap();
assert_eq!(uri.user_info(), Some("user:info"));

pub fn host(&self) -> Option<&str>[src]

Returns host of this Uri.

Example

use http_req::uri::Uri;

let uri: Uri = "https://user:info@foo.com:12/bar/baz?query#fragment".parse().unwrap();
assert_eq!(uri.host(), Some("foo.com"));

pub fn host_header(&self) -> Option<String>[src]

Returns host of this Uri to use in a header.

Example

use http_req::uri::Uri;

let uri: Uri = "https://user:info@foo.com:12/bar/baz?query#fragment".parse().unwrap();
assert_eq!(uri.host_header(), Some("foo.com:12".to_string()));

pub fn port(&self) -> Option<u16>[src]

Returns port of this Uri

Example

use http_req::uri::Uri;

let uri: Uri = "https://user:info@foo.com:12/bar/baz?query#fragment".parse().unwrap();
assert_eq!(uri.port(), Some(12));

pub fn corr_port(&self) -> u16[src]

Returns port corresponding to this Uri. Returns default port if it hasn't been set in the uri.

Example

use http_req::uri::Uri;

let uri: Uri = "https://user:info@foo.com:12/bar/baz?query#fragment".parse().unwrap();
assert_eq!(uri.corr_port(), 12);

pub fn path(&self) -> Option<&str>[src]

Returns path of this Uri.

Example

use http_req::uri::Uri;

let uri: Uri = "https://user:info@foo.com:12/bar/baz?query#fragment".parse().unwrap();
assert_eq!(uri.path(), Some("/bar/baz"));

pub fn query(&self) -> Option<&str>[src]

Returns query of this Uri.

Example

use http_req::uri::Uri;

let uri: Uri = "https://user:info@foo.com:12/bar/baz?query#fragment".parse().unwrap();
assert_eq!(uri.query(), Some("query"));

pub fn fragment(&self) -> Option<&str>[src]

Returns fragment of this Uri.

Example

use http_req::uri::Uri;

let uri: Uri = "https://user:info@foo.com:12/bar/baz?query#fragment".parse().unwrap();
assert_eq!(uri.fragment(), Some("fragment"));

pub fn resource(&self) -> &str[src]

Returns resource Uri points to.

Example

use http_req::uri::Uri;

let uri: Uri = "https://user:info@foo.com:12/bar/baz?query#fragment".parse().unwrap();
assert_eq!(uri.resource(), "/bar/baz?query#fragment");

Trait Implementations

impl Clone for Uri[src]

impl Debug for Uri[src]

impl Display for Uri[src]

impl FromStr for Uri[src]

type Err = Error

The associated error which can be returned from parsing.

impl PartialEq<Uri> for Uri[src]

impl StructuralPartialEq for Uri[src]

Auto Trait Implementations

impl RefUnwindSafe for Uri

impl Send for Uri

impl Sync for Uri

impl Unpin for Uri

impl UnwindSafe for Uri

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.