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 std::{env,fs::File};
|
||||
use std::{env,fmt,fs::File};
|
||||
use std::io::BufReader;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
@ -48,6 +48,17 @@ struct PortRegistration {
|
|||
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 {
|
||||
pub fn new() -> Self {
|
||||
Ctx { ports: HashMap::new() }
|
||||
|
@ -138,12 +149,7 @@ fn main() -> Result<ExitCode> {
|
|||
have_conflicts = true;
|
||||
println!("Conflict in site {}, port {:?}:", &datacenter, port);
|
||||
for reg in ®s {
|
||||
println!("- in {}, job \"{}\", group \"{}\", task \"{}\", service \"{}\"",
|
||||
reg.file.display(), reg.job, reg.group, reg.task,
|
||||
match ®.service {
|
||||
None => "<noname>",
|
||||
Some(s) => s
|
||||
})
|
||||
println!("- {}", reg)
|
||||
}
|
||||
println!()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue