Use a PathBuf instead of a String for storing the mmdb locations

This commit is contained in:
Slatian
2025-04-11 21:49:36 +02:00
parent 34e5e8f95c
commit f01f6a886d
2 changed files with 9 additions and 7 deletions

View File

@ -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(()),
}
}