Skip to main content

IpIntel

Trait IpIntel 

Source
pub trait IpIntel:
    Send
    + Sync
    + 'static {
    // Required method
    fn lookup(&self, ip: IpAddr) -> IpInfo;
}
Expand description

A geolocation / ASN source. Without one, IP changes are judged by network prefix only.

Lookups run on the request path and must be fast and non-blocking. With the maxmind feature, MaxMindIntel reads GeoLite2 / GeoIP2 databases held in memory.

Required Methods§

Source

fn lookup(&self, ip: IpAddr) -> IpInfo

Looks up ip. Return empty fields for unknown addresses; never panic.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: IpIntel + ?Sized> IpIntel for Arc<T>

Lets the guard share a source the app keeps a handle to, for example to reload MaxMind databases.

Source§

fn lookup(&self, ip: IpAddr) -> IpInfo

Implementors§

Source§

impl IpIntel for MaxMindIntel

Available on crate feature maxmind only.
Source§

impl IpIntel for NoIpIntel

Source§

impl<F> IpIntel for F
where F: Fn(IpAddr) -> IpInfo + Send + Sync + 'static,