Refacto structures definition
This commit is contained in:
19
virtweb_backend/src/utils/net_utils.rs
Normal file
19
virtweb_backend/src/utils/net_utils.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
|
||||
|
||||
pub fn extract_ipv4(ip: IpAddr) -> Ipv4Addr {
|
||||
match ip {
|
||||
IpAddr::V4(i) => i,
|
||||
IpAddr::V6(_) => {
|
||||
panic!("IPv6 found in IPv4 definition!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn extract_ipv6(ip: IpAddr) -> Ipv6Addr {
|
||||
match ip {
|
||||
IpAddr::V4(_) => {
|
||||
panic!("IPv4 found in IPv6 definition!")
|
||||
}
|
||||
IpAddr::V6(i) => i,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user