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]
impl BaseUrl
pub fn as_str(&self) -> &str
[src]
pub fn as_str(&self) -> &str
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 );
pub fn into_string(self) -> String
[src]
pub fn into_string(self) -> String
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 );
pub fn origin(&self) -> OriginTuple
[src]
pub fn origin(&self) -> OriginTuple
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 ) );
pub fn scheme(&self) -> &str
[src]
pub fn scheme(&self) -> &str
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( ) );
pub fn set_scheme(&mut self, scheme: &str) -> Result<(), ()>
[src]
pub fn set_scheme(&mut self, scheme: &str) -> Result<(), ()>
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+.-]+
pub fn username(&self) -> &str
[src]
pub fn username(&self) -> &str
Return the username for this BaseUrl. If no username is set an empty string is returned
pub fn set_username(&mut self, username: &str)
[src]
pub fn set_username(&mut self, username: &str)
Change the username of this BaseUrl.
pub fn password(&self) -> Option<&str>
[src]
pub fn password(&self) -> Option<&str>
Optionally returns the password associated with this BaseUrl as a percent-encoded ASCII string.
pub fn set_password(&mut self, password: Option<&str>)
[src]
pub fn set_password(&mut self, password: Option<&str>)
Change the password of this BaseUrl. Use None to remove the password field.
pub fn host_str(&self) -> &str
[src]
pub fn host_str(&self) -> &str
Returns the domain or IP address for this BaseUrl as a string.
See also the host() method
pub fn host(&self) -> Host<&str>
[src]
pub fn host(&self) -> Host<&str>
Returns the host for this BaseUrl in an enumerated type.
pub fn set_host(&mut self, host: &str) -> Result<(), ()>
[src]
pub fn set_host(&mut self, host: &str) -> Result<(), ()>
Changes the host for this BaseUrl. If there is any error parsing the provided string no action is taken and Err() is returned
pub fn set_ip_host(&mut self, address: IpAddr)
[src]
pub fn set_ip_host(&mut self, address: IpAddr)
Change this BaseUrl's host to the given Ip address.
This skips the parsing step compared to calling set_host()
pub fn domain(&self) -> Option<&str>
[src]
pub fn domain(&self) -> Option<&str>
Return's the domain string of this BaseUrl. Returns None if the host is an Ip address rather than a domain name.
pub fn port(&self) -> Option<u16>
[src]
pub fn port(&self) -> Option<u16>
Optionally return's the port number of this BaseUrl.
pub fn port_or_known_default(&self) -> Option<u16>
[src]
pub fn port_or_known_default(&self) -> Option<u16>
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.
pub fn set_port(&mut self, port: Option<u16>)
[src]
pub fn set_port(&mut self, port: Option<u16>)
Change this BaseUrl's port.
pub fn path(&self) -> &str
[src]
pub fn path(&self) -> &str
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>pub fn path_segments(&self) -> Split<char>
[src]
pub fn path_segments(&self) -> Split<char>
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.
pub fn set_path(&mut self, path: &str)
[src]
pub fn set_path(&mut self, path: &str)
Change this BaseUrl's path
pub fn path_segments_mut(&mut self) -> PathSegmentsMut
[src]
pub fn path_segments_mut(&mut self) -> PathSegmentsMut
Returns an object with methods to manipulate this BaseUrl's path segments.
pub fn query(&self) -> Option<&str>
[src]
pub fn query(&self) -> Option<&str>
Optionally return's this BaseUrl's percent-encoded query string.
ⓘImportant traits for Parse<'a>pub fn query_pairs(&self) -> Parse
[src]
pub fn query_pairs(&self) -> Parse
Parse the BaseUrl's query string and return an iterator over all found (key, value) pairs.
pub fn set_query(&mut self, query: Option<&str>)
[src]
pub fn set_query(&mut self, query: Option<&str>)
Change this BaseUrl's query string.
pub fn query_pairs_mut(&mut self) -> Serializer<UrlQuery>
[src]
pub fn query_pairs_mut(&mut self) -> Serializer<UrlQuery>
Returns an object with a method chaining API. These methods manipulate the query string of the BaseUrl as a sequence of (key, value) pairs.
pub fn fragment(&self) -> Option<&str>
[src]
pub fn fragment(&self) -> Option<&str>
Optionally returns this BaseUrl's fragment identifier.
pub fn set_fragment(&mut self, fragment: Option<&str>)
[src]
pub fn set_fragment(&mut self, fragment: Option<&str>)
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]
impl Clone for BaseUrl
fn clone(&self) -> BaseUrl
[src]
fn clone(&self) -> BaseUrl
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for BaseUrl
[src]
impl Debug for BaseUrl
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for BaseUrl
[src]
impl PartialEq for BaseUrl
fn eq(&self, other: &BaseUrl) -> bool
[src]
fn eq(&self, other: &BaseUrl) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &BaseUrl) -> bool
[src]
fn ne(&self, other: &BaseUrl) -> bool
This method tests for !=
.
impl Eq for BaseUrl
[src]
impl Eq for BaseUrl
impl PartialOrd for BaseUrl
[src]
impl PartialOrd for BaseUrl
fn partial_cmp(&self, other: &BaseUrl) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &BaseUrl) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &BaseUrl) -> bool
[src]
fn lt(&self, other: &BaseUrl) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &BaseUrl) -> bool
[src]
fn le(&self, other: &BaseUrl) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &BaseUrl) -> bool
[src]
fn gt(&self, other: &BaseUrl) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &BaseUrl) -> bool
[src]
fn ge(&self, other: &BaseUrl) -> bool
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]
impl Ord for BaseUrl
fn cmp(&self, other: &BaseUrl) -> Ordering
[src]
fn cmp(&self, other: &BaseUrl) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Hash for BaseUrl
[src]
impl Hash for BaseUrl
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl From<BaseUrl> for Url
[src]
impl From<BaseUrl> for Url
impl TryFrom<Url> for BaseUrl
[src]
impl TryFrom<Url> for BaseUrl
impl<'a> TryFrom<&'a str> for BaseUrl
[src]
impl<'a> TryFrom<&'a str> for BaseUrl
impl Display for BaseUrl
[src]
impl Display for BaseUrl
fn fmt(&self, formatter: &mut Formatter) -> FormatResult
[src]
fn fmt(&self, formatter: &mut Formatter) -> FormatResult
Formats the value using the given formatter. Read more