minor improvements

This commit is contained in:
Giuliano Bellini s294739
2024-02-07 22:15:27 +01:00
parent 1107817f45
commit 502140acbd
2 changed files with 12 additions and 9 deletions

View File

@@ -8,9 +8,12 @@
include!("./src/networking/types/service_query.rs");
include!("./src/networking/types/protocol.rs");
include!("./src/networking/types/service.rs");
const SERVICES_LIST_PATH: &str = "./services.txt";
fn main() {
println!("cargo:rerun-if-changed={SERVICES_LIST_PATH}");
set_icon();
build_services_phf();
}
@@ -30,7 +33,7 @@ fn build_services_phf() {
let mut services_map = phf_codegen::Map::new();
let input = BufReader::new(File::open("./services.txt").unwrap());
let input = BufReader::new(File::open(SERVICES_LIST_PATH).unwrap());
for line_res in input.lines() {
// we want to panic if one of the lines is err...
let line = line_res.unwrap();
@@ -77,10 +80,3 @@ fn get_valid_service_query(s: &str) -> ServiceQuery {
assert!(parts.next().is_none());
ServiceQuery(port, protocol)
}
impl phf_shared::FmtConst for ServiceQuery {
fn fmt_const(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let ServiceQuery(port, protocol) = self;
write!(f, "ServiceQuery({port}, Protocol::{protocol})",)
}
}

View File

@@ -17,3 +17,10 @@ fn borrow(&self) -> &ServiceQuery {
self
}
}
impl phf_shared::FmtConst for ServiceQuery {
fn fmt_const(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let ServiceQuery(port, protocol) = self;
write!(f, "ServiceQuery({port}, Protocol::{protocol})",)
}
}