pub enum Network {
Host(IpAddr),
Network(IpNet),
Range(IpRange),
Fqdn(Fqdn),
}Variants§
Implementations§
Source§impl Network
impl Network
Sourcepub fn new(input: &str) -> Result<Self, String>
pub fn new(input: &str) -> Result<Self, String>
Create a Network from a string.
Detection order:
- Host IP
- CIDR network
- IP range
- FQDN
§Examples
Parse a host address:
use firewall_objects::ip::network::Network;
let n = Network::new("192.0.2.10").unwrap();
assert!(matches!(n, Network::Host(_)));Parse a CIDR network:
use firewall_objects::ip::network::Network;
let n = Network::new("192.0.2.0/24").unwrap();
assert!(matches!(n, Network::Network(_)));Parse an IP range:
use firewall_objects::ip::network::Network;
let n = Network::new("192.0.2.50 - 192.0.2.100").unwrap();
assert!(matches!(n, Network::Range(_)));Parse an FQDN:
use firewall_objects::ip::network::Network;
let n = Network::new("www.example.com").unwrap();
assert!(matches!(n, Network::Fqdn(_)));§Errors
Return Err if the input cannot be parsed as a valid network value.
Trait Implementations§
Source§impl FromStr for Network
impl FromStr for Network
Source§impl Ord for Network
impl Ord for Network
Source§impl PartialOrd for Network
impl PartialOrd for Network
impl Eq for Network
impl StructuralPartialEq for Network
Auto Trait Implementations§
impl Freeze for Network
impl RefUnwindSafe for Network
impl Send for Network
impl Sync for Network
impl Unpin for Network
impl UnwindSafe for Network
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