pub struct Authority(/* private fields */);Expand description
URL authority: [userinfo "@"] host [":" port].
Implementations§
Source§impl Authority
impl Authority
Sourcepub fn new(src: &str) -> Result<&Authority, InvalidUrl>
pub fn new(src: &str) -> Result<&Authority, InvalidUrl>
Strictly validates an authority.
use urly::{Authority, ErrorKind};
let auth = Authority::new("user:[email protected]:8080").unwrap();
assert_eq!(auth.host(), "example.com");
assert_eq!(auth.port_u16(), Some(8080));
assert_eq!(auth.userinfo().unwrap().password(), Some("pw"));
let err = Authority::new("example.com:99999").unwrap_err();
assert_eq!(err.kind(), ErrorKind::PortOutOfRange);Sourcepub fn from_static(src: &'static str) -> &'static Authority
pub fn from_static(src: &'static str) -> &'static Authority
Sourcepub fn host_port(&self) -> &str
pub fn host_port(&self) -> &str
Returns the authority without the userinfo.
use urly::Authority;
let auth = Authority::new("user:[email protected]:8080").unwrap();
assert_eq!(auth.host_port(), "example.com:8080");