Struct base_url::BaseUrl[][src]

pub struct BaseUrl { /* fields omitted */ }

Any Url which has a host and so can be supplied as a base url

Methods

impl BaseUrl
[src]

Return the serialization of this BaseUrl

This is fast, since internally the Url stores the serialization already

Examples

use base_url::{ BaseUrl, Url };
let url_str = "https://example.org/"
let host = BaseUrl::try_from( url_str )?;
assert_eq!( host.as_str( ), url_str );

Return the serialization of this BaseUrl

This consumes the BaseUrl and takes ownership of the String

Examples

use base_url::BaseUrl;
let url_str = "https://example.org/"
let host = BaseUrl::try_from( url_str )?;
assert_eq!( host.into_string, url_str );

Returns the BaseUrl's scheme, host and port as a tuple

Examples

use base_url::{ BaseUrl, OriginTuple, Host };
let url = BaseUrl::try_from( "ftp://example.org/foo" );

assert_eq!( url.origin( ),
            ( "ftp".into( ),
              Host::Domain( "example.org".into( ) ),
              21 ) );

Returns the scheme of the given BaseUrl, lower-cased, as an ASCII string without the ':' delimiter

Examples

use base_url::BaseUrl;
let url = BaseUrl::try_from( "https://example.org" )?;
assert_eq!( url.scheme, "https".into( ) );

Set the BaseUrl's scheme

Does nothing and returns Err() if the specified scheme does not match the regular expression [a-zA-Z][a-zA-Z0-9+.-]+

Return the username for this BaseUrl. If no username is set an empty string is returned

Change the username of this BaseUrl.

Optionally returns the password associated with this BaseUrl as a percent-encoded ASCII string.

Change the password of this BaseUrl. Use None to remove the password field.

Returns the domain or IP address for this BaseUrl as a string.

See also the host() method

Returns the host for this BaseUrl in an enumerated type.

Changes the host for this BaseUrl. If there is any error parsing the provided string no action is taken and Err() is returned

Change this BaseUrl's host to the given Ip address.

This skips the parsing step compared to calling set_host()

Return's the domain string of this BaseUrl. Returns None if the host is an Ip address rather than a domain name.

Optionally return's the port number of this BaseUrl.

Return's the port number of this BaseUrl. If no port number is present a guess is made based on the scheme, if no guess can be made None is returned.

Change this BaseUrl's port.

Return's the path of this BaseUrl, percent-encoded. Path strings will start with '/' and continue with '/' separated path segments.

Important traits for Split<'a, P>

Return's an iterator through each of this BaseUrl's path segments. Path segments do not contain the separating '/' characters and may be empty, often on the last entry.

Change this BaseUrl's path

Returns an object with methods to manipulate this BaseUrl's path segments.

Optionally return's this BaseUrl's percent-encoded query string.

Important traits for Parse<'a>

Parse the BaseUrl's query string and return an iterator over all found (key, value) pairs.

Change this BaseUrl's query string.

Returns an object with a method chaining API. These methods manipulate the query string of the BaseUrl as a sequence of (key, value) pairs.

Optionally returns this BaseUrl's fragment identifier.

Change this BaseUrl's fragment identifier.

The fragment is any text placed after a # symbol in the Url. It is meant to refer to a secondary resource.

This is often not sent to the server where it is used in http: and similar schemes.

Trait Implementations

impl Clone for BaseUrl
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for BaseUrl
[src]

Formats the value using the given formatter. Read more

impl PartialEq for BaseUrl
[src]

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

This method tests for !=.

impl Eq for BaseUrl
[src]

impl PartialOrd for BaseUrl
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for BaseUrl
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl Hash for BaseUrl
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl From<BaseUrl> for Url
[src]

Performs the conversion.

impl TryFrom<Url> for BaseUrl
[src]

impl<'a> TryFrom<&'a str> for BaseUrl
[src]

impl Display for BaseUrl
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for BaseUrl

impl Sync for BaseUrl