Struct libloc::Network

source ·
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>

source

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");
source

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);
source

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);
source

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);
source

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);
source

pub fn is_drop(&self) -> bool

source

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§

source§

impl<'a> Debug for Network<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<NetworkV4<'a>> for Network<'a>

source§

fn from(network: NetworkV4<'a>) -> Network<'a>

Converts to this type from the input type.
source§

impl<'a> From<NetworkV6<'a>> for Network<'a>

source§

fn from(network: NetworkV6<'a>) -> Network<'a>

Converts to this type from the input type.

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> ErasedDestructor for T
where T: 'static,