Skip to content

Commit

Permalink
Merge pull request #561 from zeenix/abstract-socket-osstring
Browse files Browse the repository at this point in the history
🏷️ zb: Represent abstract socket name as OsString
  • Loading branch information
zeenix authored Feb 1, 2024
2 parents ce3092d + 89e2c97 commit 343e1e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion zbus/src/address/transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ impl Transport {
#[cfg(windows)]
UnixPath::File(path) => path,
#[cfg(target_os = "linux")]
UnixPath::Abstract(name) => SocketAddr::from_abstract_name(name)?,
UnixPath::Abstract(name) => {
SocketAddr::from_abstract_name(name.as_encoded_bytes())?
}
UnixPath::Dir(_) | UnixPath::TmpDir(_) => {
// you can't connect to a unix:dir
return Err(Error::Unsupported);
Expand Down
6 changes: 3 additions & 3 deletions zbus/src/address/transport/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Unix {
let path = match (path, abs, dir, tmpdir) {
(Some(p), None, None, None) => UnixPath::File(OsString::from(p)),
#[cfg(target_os = "linux")]
(None, Some(p), None, None) => UnixPath::Abstract(p.as_bytes().to_owned()),
(None, Some(p), None, None) => UnixPath::Abstract(OsString::from(p)),
#[cfg(not(target_os = "linux"))]
(None, Some(_), None, None) => {
return Err(crate::Error::Address(
Expand Down Expand Up @@ -70,7 +70,7 @@ pub enum UnixPath {
File(OsString),
/// A abstract unix domain socket name.
#[cfg(target_os = "linux")]
Abstract(Vec<u8>),
Abstract(OsString),
/// A listenable address using the specified path, in which a socket file with a random file
/// name starting with 'dbus-' will be created by the server. See [UNIX domain socket address]
/// reference documentation.
Expand Down Expand Up @@ -111,7 +111,7 @@ impl Display for UnixPath {
#[cfg(target_os = "linux")]
UnixPath::Abstract(name) => {
f.write_str("abstract=")?;
encode_percents(f, name)?;
fmt_unix_path(f, name)?;
}
UnixPath::Dir(path) => {
f.write_str("dir=")?;
Expand Down

0 comments on commit 343e1e6

Please sign in to comment.