mirror of
https://codeberg.org/slatian/service.echoip-slatecave.git
synced 2025-07-16 22:13:30 +02:00
Threw out some unneeded api
This commit is contained in:
12
src/geoip.rs
12
src/geoip.rs
@ -50,11 +50,11 @@ pub struct MMDBCarrier {
|
||||
}
|
||||
|
||||
pub trait QueryLocation {
|
||||
fn query_location_for_ip(&self, address: IpAddr, laguages: &Vec<&String>) -> Option<LocationResult>;
|
||||
fn query_location_for_ip(&self, address: &IpAddr, laguages: &Vec<&String>) -> Option<LocationResult>;
|
||||
}
|
||||
|
||||
pub trait QueryAsn {
|
||||
fn query_asn_for_ip(&self, address: IpAddr) -> Option<AsnResult>;
|
||||
fn query_asn_for_ip(&self, address: &IpAddr) -> Option<AsnResult>;
|
||||
}
|
||||
|
||||
/* Converters */
|
||||
@ -119,10 +119,10 @@ pub fn geoip2_subdivision_to_named_location(item: geoip2::model::Subdivision, la
|
||||
/* Implementation */
|
||||
|
||||
impl QueryAsn for MMDBCarrier {
|
||||
fn query_asn_for_ip(&self, address: IpAddr) -> Option<AsnResult> {
|
||||
fn query_asn_for_ip(&self, address: &IpAddr) -> Option<AsnResult> {
|
||||
match &self.mmdb {
|
||||
Some(mmdb) => {
|
||||
match mmdb.lookup::<geoip2::Asn>(address) {
|
||||
match mmdb.lookup::<geoip2::Asn>(*address) {
|
||||
Ok(res) => {
|
||||
Some(AsnResult {
|
||||
asn: res.autonomous_system_number,
|
||||
@ -141,10 +141,10 @@ impl QueryAsn for MMDBCarrier {
|
||||
}
|
||||
|
||||
impl QueryLocation for MMDBCarrier {
|
||||
fn query_location_for_ip(&self, address: IpAddr, languages: &Vec<&String>) -> Option<LocationResult> {
|
||||
fn query_location_for_ip(&self, address: &IpAddr, languages: &Vec<&String>) -> Option<LocationResult> {
|
||||
match &self.mmdb {
|
||||
Some(mmdb) => {
|
||||
match mmdb.lookup::<geoip2::City>(address) {
|
||||
match mmdb.lookup::<geoip2::City>(*address) {
|
||||
Ok(res) => {
|
||||
Some(LocationResult {
|
||||
continent:
|
||||
|
Reference in New Issue
Block a user