Skip to content

Commit

Permalink
Merge pull request #52 from Polochon-street/fix-non-linux-oses
Browse files Browse the repository at this point in the history
Fix compilation for non-linux OSes
  • Loading branch information
Polochon-street authored Feb 9, 2024
2 parents 27f4a42 + bce6651 commit 8b63ebf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## blissify 0.3.10
* Fix compilation for non-linux OSes

## blissify 0.3.9
* Add support for hostnames and abstract sockets in MPD_HOST

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blissify"
version = "0.3.9"
version = "0.3.10"
authors = ["Polochon-street <[email protected]>"]
edition = "2021"
license = "GPL-3.0-only"
Expand Down
23 changes: 14 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl MPDLibrary {
/// variables.
#[cfg(not(test))]
fn get_mpd_conn() -> Result<Client<MPDStream>> {
#[cfg(target_os = "linux")]
use std::os::linux::net::SocketAddrExt;
use std::os::unix::net::SocketAddr;

Expand Down Expand Up @@ -161,18 +162,22 @@ impl MPDLibrary {
// find a solution that doesn't depend on a url crate that pulls the entire internet
// with it
if mpd_host.starts_with('/') || mpd_host.starts_with('~') {
Client::new(MPDStream::Unix(UnixStream::connect(mpd_host)?))?
} else if mpd_host.starts_with('@') {
return Ok(Client::new(MPDStream::Unix(UnixStream::connect(
mpd_host,
)?))?);
}
#[cfg(target_os = "linux")]
if mpd_host.starts_with('@') {
let addr = SocketAddr::from_abstract_name(mpd_host.split_once('@').unwrap().1)?;
Client::new(MPDStream::Unix(UnixStream::connect_addr(&addr)?))?
return Ok(Client::new(MPDStream::Unix(UnixStream::connect_addr(
&addr,
)?))?);
}
// It is a hostname or an IP address
else {
Client::new(MPDStream::Tcp(TcpStream::connect(format!(
"{}:{}",
mpd_host, mpd_port
))?))?
}
Client::new(MPDStream::Tcp(TcpStream::connect(format!(
"{}:{}",
mpd_host, mpd_port
))?))?
};
if let Some(pw) = password {
client.login(&pw)?;
Expand Down

0 comments on commit 8b63ebf

Please sign in to comment.