pub struct Network<'a> { /* private fields */ }
Expand description
Information on an IP network.
Returned by the Locations::lookup
function.
Implementations§
source§impl<'a> Network<'a>
impl<'a> Network<'a>
sourcepub fn country_code(&self) -> &'a str
pub fn country_code(&self) -> &'a str
The ISO 3166-1 alpha-2 country code of the country associated with this network.
"XX"
if unknown.
use libloc::Locations;
let locations = Locations::open("example-location.db")?;
let network: libloc::Network = locations.lookup("2a07:1c44:5800::1".parse().unwrap()).unwrap();
assert_eq!(network.country_code(), "DE");
sourcepub fn asn(&self) -> u32
pub fn asn(&self) -> u32
The ASN of this network.
0 if unknown.
use libloc::Locations;
let locations = Locations::open("example-location.db")?;
let network: libloc::Network = locations.lookup("2a07:1c44:5800::1".parse().unwrap()).unwrap();
assert_eq!(network.asn(), 204867);
sourcepub fn is_anonymous_proxy(&self) -> bool
pub fn is_anonymous_proxy(&self) -> bool
Whether the network hosts anonymous proxies.
use libloc::Locations;
let locations = Locations::open("example-location.db")?;
let network: libloc::Network = locations.lookup("2a07:1c44:5800::1".parse().unwrap()).unwrap();
assert_eq!(network.is_anonymous_proxy(), false);
sourcepub fn is_satellite_provider(&self) -> bool
pub fn is_satellite_provider(&self) -> bool
Whether the network is a satellite provider.
use libloc::Locations;
let locations = Locations::open("example-location.db")?;
let network: libloc::Network = locations.lookup("2a07:1c44:5800::1".parse().unwrap()).unwrap();
assert_eq!(network.is_satellite_provider(), false);
sourcepub fn is_anycast(&self) -> bool
pub fn is_anycast(&self) -> bool
Whether the network consists of anycast addresses.
use libloc::Locations;
let locations = Locations::open("example-location.db")?;
let network: libloc::Network = locations.lookup("2a07:1c44:5800::1".parse().unwrap()).unwrap();
assert_eq!(network.is_anycast(), true);
pub fn is_drop(&self) -> bool
sourcepub fn addrs(&self) -> IpNet
pub fn addrs(&self) -> IpNet
All the addresses belonging to this particular network.
use libloc::Locations;
let locations = Locations::open("example-location.db")?;
let network: libloc::Network = locations.lookup("2a07:1c44:5800::1".parse().unwrap()).unwrap();
assert_eq!(network.addrs().to_string(), "2a07:1c44:5800::/40");
Trait Implementations§
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Network<'a>
impl<'a> Send for Network<'a>
impl<'a> Sync for Network<'a>
impl<'a> Unpin for Network<'a>
impl<'a> UnwindSafe for Network<'a>
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