Struct Db

Source
pub struct Db(/* private fields */);
Expand description

ASN record database that is optimized for lookup by an IP address.

Implementations§

Source§

impl Db

Source

pub fn form_tsv(data: impl Read) -> Result<Db, DbError>

Loads database from ASN data as provided by IPtoASN - the only supported file format is of ip2asn-v4.tsv file.

Source

pub fn load(db_data: impl Read) -> Result<Db, DbError>

Loads database from the binary index that was stored with .store() - this method is much faster than loading from the TSV file.

Source

pub fn store(&self, db_data: impl Write) -> Result<(), DbError>

Stores database as a binary index for fast loading with .load().

Source

pub fn lookup(&self, ip: Ipv4Addr) -> Option<&Record>

Performs lookup by an IP address for the ASN Record of which network this IP belongs to.

Trait Implementations§

Source§

impl Debug for Db

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Db

§

impl RefUnwindSafe for Db

§

impl Send for Db

§

impl Sync for Db

§

impl Unpin for Db

§

impl UnwindSafe for Db

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> ToErrorNoContext<T> for T

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<E, C> WrapContext<C> for E

Source§

type ContextError = ErrorContext<E, C>

Source§

fn wrap_context(self, context: C) -> ErrorContext<E, C>