mirror of
https://codeberg.org/slatian/service.echoip-slatecave.git
synced 2025-07-19 15:26:03 +02:00
Use a PathBuf instead of a String for storing the mmdb locations
This commit is contained in:
@ -11,6 +11,7 @@ use parking_lot::RwLock;
|
||||
use std::collections::BTreeMap;
|
||||
use std::net::IpAddr;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
/* Datatypes */
|
||||
|
||||
@ -51,7 +52,7 @@ pub struct AsnResult {
|
||||
pub struct MMDBCarrier {
|
||||
pub mmdb: RwLock<Option<maxminddb::Reader<Vec<u8>>>>,
|
||||
pub name: String,
|
||||
pub path: Option<String>,
|
||||
pub path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
pub trait QueryLocation {
|
||||
@ -227,7 +228,7 @@ impl QueryLocation for MMDBCarrier {
|
||||
}
|
||||
|
||||
impl MMDBCarrier {
|
||||
pub fn new(name: String, path: Option<String>) -> MMDBCarrier {
|
||||
pub fn new(name: String, path: Option<PathBuf>) -> MMDBCarrier {
|
||||
MMDBCarrier {
|
||||
mmdb: RwLock::new(None),
|
||||
name: name,
|
||||
@ -237,7 +238,7 @@ impl MMDBCarrier {
|
||||
|
||||
pub fn reload_database(&self) -> Result<(),maxminddb::MaxMindDbError> {
|
||||
match &self.path {
|
||||
Some(path) => self.load_database_from_path(Path::new(&path)),
|
||||
Some(path) => self.load_database_from_path(path),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user