add Display impl for printing PortRegistration
This commit is contained in:
parent
9cb4f6c11e
commit
734d97e191
1 changed files with 13 additions and 7 deletions
20
src/main.rs
20
src/main.rs
|
@ -1,5 +1,5 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{env,fs::File};
|
use std::{env,fmt,fs::File};
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -48,6 +48,17 @@ struct PortRegistration {
|
||||||
service: Option<String>,
|
service: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for PortRegistration {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "in {}, job \"{}\", group \"{}\", task \"{}\", service \"{}\"",
|
||||||
|
self.file.display(), self.job, self.group, self.task,
|
||||||
|
match &self.service {
|
||||||
|
None => "<noname>",
|
||||||
|
Some(s) => s
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Ctx {
|
impl Ctx {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Ctx { ports: HashMap::new() }
|
Ctx { ports: HashMap::new() }
|
||||||
|
@ -138,12 +149,7 @@ fn main() -> Result<ExitCode> {
|
||||||
have_conflicts = true;
|
have_conflicts = true;
|
||||||
println!("Conflict in site {}, port {:?}:", &datacenter, port);
|
println!("Conflict in site {}, port {:?}:", &datacenter, port);
|
||||||
for reg in ®s {
|
for reg in ®s {
|
||||||
println!("- in {}, job \"{}\", group \"{}\", task \"{}\", service \"{}\"",
|
println!("- {}", reg)
|
||||||
reg.file.display(), reg.job, reg.group, reg.task,
|
|
||||||
match ®.service {
|
|
||||||
None => "<noname>",
|
|
||||||
Some(s) => s
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
println!()
|
println!()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue