dbus_server_address_parser/encode/
unix.rs1use super::{escape::escape, guid::to_guid};
2use crate::{Unix, UnixType};
3use std::fmt::{Display, Formatter, Result as FmtResult};
4
5impl Display for Unix {
6 fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
7 write!(f, "unix:")?;
8 self.r#type.fmt(f)?;
9 if let Some(guid) = &self.guid {
10 write!(f, ",guid={}", to_guid(guid))
11 } else {
12 Ok(())
13 }
14 }
15}
16
17impl Display for UnixType {
18 fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
19 match self {
20 UnixType::Path(path) => write!(f, "path={}", escape(path)),
21 UnixType::Dir(dir) => write!(f, "dir={}", escape(dir)),
22 UnixType::Tmpdir(tmp_dir) => write!(f, "tmpdir={}", escape(tmp_dir)),
23 UnixType::Abstract(abstract_) => write!(f, "abstract={}", escape(abstract_)),
24 UnixType::Runtime => write!(f, "runtime=yes"),
25 }
26 }
27}