pub enum Port {
None,
Any,
Val(u16),
NoneVal(u16),
}Expand description
A TCP/UDP port. This can be used to make origin validation more convenient.
Variants§
None
A port must not exist when validating the origin.
Any
Any port, or no port at all, is allowed to exist when validating the origin.
Val(u16)
The contained u16 port must exist when validating the origin.
NoneVal(u16)
Self::None or Self::Val.
Trait Implementations§
impl Copy for Port
Source§impl FromStr for Port
impl FromStr for Port
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses s as a 16-bit unsigned integer without leading 0s returning Self::Val with the contained
u16.
§Errors
Errors iff s is not a valid 16-bit unsigned integer in decimal notation without leading 0s.
§Examples
assert!(matches!("443".parse()?, Port::Val(443)));
// TCP/UDP ports have to be in canonical form:
assert!("022"
.parse::<Port>()
.map_or_else(|err| matches!(err, PortParseErr::NotCanonical), |_| false));Source§type Err = PortParseErr
type Err = PortParseErr
The associated error which can be returned from parsing.
Auto Trait Implementations§
impl Freeze for Port
impl RefUnwindSafe for Port
impl Send for Port
impl Sync for Port
impl Unpin for Port
impl UnsafeUnpin for Port
impl UnwindSafe for Port
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more