Struct fluent_uri::Authority
source · #[repr(transparent)]pub struct Authority<T: Storage> { /* private fields */ }
Expand description
The authority component of URI reference.
Implementations§
source§impl<'i, 'o, T: Io<'i, 'o>> Authority<T>
impl<'i, 'o, T: Io<'i, 'o>> Authority<T>
sourcepub fn port(&'i self) -> Option<&'o str>
pub fn port(&'i self) -> Option<&'o str>
Returns the port subcomponent.
Note that in the generic URI syntax, the port may be empty, with leading zeros, or very large. It is up to you to decide whether to deny such a port, fallback to the scheme’s default if it is empty, ignore the leading zeros, or use a different addressing mechanism that allows a large port.
Examples
use fluent_uri::Uri;
let uri = Uri::parse("ssh://device.local:4673/")?;
let authority = uri.authority().unwrap();
assert_eq!(authority.port(), Some("4673"));
let uri = Uri::parse("ssh://device.local:/")?;
let authority = uri.authority().unwrap();
assert_eq!(authority.port(), Some(""));
let uri = Uri::parse("ssh://device.local/")?;
let authority = uri.authority().unwrap();
assert_eq!(authority.port(), None);