DbIpDatabase

Struct DbIpDatabase 

Source
pub struct DbIpDatabase<V> { /* private fields */ }
Expand description

A map of ip range to data derived from a country code.

Implementations§

Source§

impl<V> DbIpDatabase<V>
where V: IpData,

Source

pub fn get(&self, ip: &IpAddr) -> Option<V>

Gets the value associated with an ip address, if any.

Source

pub fn get_v4(&self, v4: &Ipv4Addr) -> Option<V>

Gets the value associated with an Ipv4 address, if any.

Source

pub fn get_v6(&self, v6: &Ipv6Addr) -> Option<V>

Gets the value associated with an Ipv6 address, if any.

Source

pub fn len(&self) -> usize

Returns number of ranges/values stored for both Ipv4 and Ipv6 addresses.

Source

pub fn len_v4(&self) -> usize

Returns number of ranges/values stored for Ipv4 addresses.

Source

pub fn len_v6(&self) -> usize

Returns number of ranges/values stored for Ipv6 addresses.

Source

pub fn from_csv_str(csv: &str) -> Result<DbIpDatabase<V>, FromCsvError>

Load from CSV file contained in string.

Source

pub fn from_csv_reader<R>(reader: R) -> Result<DbIpDatabase<V>, FromCsvError>
where R: Read,

Load from CSV file reader.

Source

pub fn from_csv_file(path: &str) -> Result<DbIpDatabase<V>, FromCsvError>

Load from CSV file contained in file.

Trait Implementations§

Source§

impl<V> Debug for DbIpDatabase<V>
where V: Debug,

Source§

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

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

impl<'de, V> Deserialize<'de> for DbIpDatabase<V>
where V: Deserialize<'de>,

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<DbIpDatabase<V>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<V> Serialize for DbIpDatabase<V>
where V: Serialize,

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<V> Freeze for DbIpDatabase<V>

§

impl<V> RefUnwindSafe for DbIpDatabase<V>
where V: RefUnwindSafe,

§

impl<V> Send for DbIpDatabase<V>
where V: Send,

§

impl<V> Sync for DbIpDatabase<V>
where V: Sync,

§

impl<V> Unpin for DbIpDatabase<V>
where V: Unpin,

§

impl<V> UnwindSafe for DbIpDatabase<V>
where V: UnwindSafe,

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>,

Source§

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>,

Source§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,