finnbear / db_ip

An (unofficial) Rust library for querying db-ip.com data
https://crates.io/crates/db_ip
Other
5 stars 0 forks source link

AS lite db availability #3

Open GyulyVGC opened 1 year ago

GyulyVGC commented 1 year ago

It would be nice to have a macro that works as the already present macro to load countries, but for querying autonomous system db.

It could be of interest to add the same support in terms of automatic fetching and compression of the latest db version as well, as already done for countries.

finnbear commented 1 year ago

It would be nice to have a macro that works as the already present macro to load countries, but for querying autonomous system db.

It's currently possible to create a DbIpDatabase<Asn> where struct Asn { number: usize, name: String } and impl IpData for Asn { ... }.

I agree that a dedicated macro and Asn in this crate would make it easier, but I think I'd rather create a more general macro. Maybe something like:

use db_ip::{include_database, Asn, DbIpDatabase};
let db: DbIpDatabase<Asn> = include_database!("asn_data.csv", Asn);

If it was a procedural macro, it emit Rust code as opposed to requiring compression/serialization of any kind (or it could just compress/serialize if the Rust code bloated the binary too much).

Anyway, while I'm currently a bit busy, I'll see if I can find some time to add this soon :)

GyulyVGC commented 1 year ago

No worries, thanks for your support mate!