dbus_server_address_parser/encode/
tcp.rs1use super::{escape::escape, guid::to_guid};
2use crate::Tcp;
3use std::fmt::{Display, Formatter, Result as FmtResult};
4
5impl Display for Tcp {
6 fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
7 write!(f, "tcp:")?;
8 let mut not_first = false;
9 if let Some(host) = &self.host {
10 write!(f, "host={}", escape(host))?;
11 not_first = true;
12 }
13
14 if let Some(bind) = &self.bind {
15 if not_first {
16 write!(f, ",")?;
17 }
18 write!(f, "bind={}", escape(bind))?;
19 not_first = true;
20 }
21
22 if let Some(port) = self.port {
23 if not_first {
24 write!(f, ",")?;
25 }
26 write!(f, "port={}", port)?;
27 not_first = true;
28 }
29
30 if let Some(family) = &self.family {
31 if not_first {
32 write!(f, ",")?;
33 }
34 family.fmt(f)?;
35 not_first = true;
36 }
37
38 if let Some(guid) = &self.guid {
39 if not_first {
40 write!(f, ",")?;
41 }
42 write!(f, "guid={}", to_guid(guid))
43 } else {
44 Ok(())
45 }
46 }
47}