[−][src]Struct rhymuri::Authority
This is the optional part of a URI which governs the URI's namespace. It typically contains a host name or IP address, and may also include a port number and/or userinfo component.
Examples
Parsing an Authority into its components
use rhymuri::Authority; let authority = Authority::parse("nobody@www.example.com:8080")?; assert_eq!(Some("nobody".as_bytes()), authority.userinfo()); assert_eq!("www.example.com".as_bytes(), authority.host()); assert_eq!(Some(8080), authority.port());
Generating a URI from its components
use rhymuri::Authority; let mut authority = Authority::default(); authority.set_userinfo(Some("nobody").map(Into::into)); authority.set_host("www.example.com"); authority.set_port(Some(8080)); assert_eq!("nobody@www.example.com:8080", authority.to_string());
Implementations
impl Authority
[src]
#[must_use = "why u no use host return value?"]pub fn host(&self) -> &[u8]
[src]
Borrow the host name part of the Authority.
#[must_use = "why did you get the port number and then throw it away?"]pub fn port(&self) -> Option<u16>
[src]
Borrow the port number part of the Authority.
pub fn set_userinfo<T>(&mut self, userinfo: T) where
T: Into<Option<Vec<u8>>>,
[src]
T: Into<Option<Vec<u8>>>,
Change the userinfo part of the Authority.
pub fn set_host<T>(&mut self, host: T) where
T: Into<Vec<u8>>,
[src]
T: Into<Vec<u8>>,
Change the host name part of the Authority.
pub fn set_port(&mut self, port: Option<u16>)
[src]
Change the port number part of the Authority.
#[must_use = "security breach... security breach... userinfo not used"]pub fn userinfo(&self) -> Option<&[u8]>
[src]
Borrow the userinfo part of the Authority.
#[must_use = "you parsed it; don't you want the results?"]pub fn parse<T>(authority_string: T) -> Result<Self, Error> where
T: AsRef<str>,
[src]
T: AsRef<str>,
Interpret the given string as the Authority component of a URI,
separating its various subcomponents, returning an Authority
value
containing them.
Errors
There are many ways to screw up the Authority part of URI string, and
this function will let you know what's up by returning a variant of the
Error
type.
Trait Implementations
impl Clone for Authority
[src]
impl Debug for Authority
[src]
impl Default for Authority
[src]
impl Display for Authority
[src]
impl PartialEq<Authority> for Authority
[src]
impl StructuralPartialEq for Authority
[src]
Auto Trait Implementations
impl RefUnwindSafe for Authority
[src]
impl Send for Authority
[src]
impl Sync for Authority
[src]
impl Unpin for Authority
[src]
impl UnwindSafe for Authority
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,