Merge #211: gui: disable daemon jsonrpc client for windows

37562608ecd9471fe37ea123fe21512b6d373068 gui: disable daemon jsonrpc client for windows (edouard)

Pull request description:

  It is not certain that uds_windows will work so we prefer
  to remove it.

ACKs for top commit:
  darosior:
    utACK 37562608ecd9471fe37ea123fe21512b6d373068. That sounds more reasonable, and removes 8 dependencies 🎉.

Tree-SHA512: f0af1ceba6dc0881d5265497c606ff9916ba9a64cb94a79b4e4b4ecce9c3800fc796f0cd2eb620abf14793efb413b88cee202ce800a4e4c237e761ef5d2ab528
This commit is contained in:
Antoine Poinsot 2022-12-13 16:00:43 +01:00
commit de629cc075
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304
7 changed files with 29 additions and 84 deletions

81
gui/Cargo.lock generated
View File

@ -935,12 +935,6 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]]
name = "futures"
version = "0.3.21"
@ -1681,7 +1675,6 @@ dependencies = [
"serde_json",
"tokio",
"toml",
"uds_windows",
]
[[package]]
@ -2338,7 +2331,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1181c94580fa345f50f19d738aaa39c0ed30a600d95cb2d3e23f94266f14fbf"
dependencies = [
"phf_shared",
"rand 0.8.5",
"rand",
]
[[package]]
@ -2472,19 +2465,6 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
dependencies = [
"fuchsia-cprng",
"libc",
"rand_core 0.3.1",
"rdrand",
"winapi",
]
[[package]]
name = "rand"
version = "0.8.5"
@ -2493,7 +2473,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core 0.6.3",
"rand_core",
]
[[package]]
@ -2503,24 +2483,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core 0.6.3",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
dependencies = [
"rand_core 0.4.2",
]
[[package]]
name = "rand_core"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rand_core"
version = "0.6.3"
@ -2594,15 +2559,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ae028b272a6e99d9f8260ceefa3caa09300a8d6c8d2b2001316474bc52122e9"
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "redox_syscall"
version = "0.2.15"
@ -2640,15 +2596,6 @@ version = "0.6.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
"winapi",
]
[[package]]
name = "renderdoc-sys"
version = "0.7.1"
@ -3049,16 +2996,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "tempdir"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
dependencies = [
"rand 0.4.6",
"remove_dir_all",
]
[[package]]
name = "termcolor"
version = "1.1.3"
@ -3209,20 +3146,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [
"cfg-if",
"rand 0.8.5",
"rand",
"static_assertions",
]
[[package]]
name = "uds_windows"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09b22bf5f590ee6a2892e134e18482e63361319cc62ed108eb236803284cefec"
dependencies = [
"tempdir",
"winapi",
]
[[package]]
name = "unicode-bidi"
version = "0.3.8"

View File

@ -36,8 +36,5 @@ toml = "0.5"
chrono = "0.4"
[target.'cfg(windows)'.dependencies]
uds_windows = "0.1.5"
[dev-dependencies]
tokio = {version = "1.9.0", features = ["rt", "macros"]}

View File

@ -31,6 +31,9 @@ impl std::fmt::Display for Error {
DaemonError::Start(e) => {
write!(f, "Failed to start daemon: {}", e)
}
DaemonError::ClientNotSupported => {
write!(f, "Daemon client is not supported")
}
DaemonError::Rpc(code, e) => {
write!(f, "[{:?}] {}", code, e)
}

View File

@ -28,6 +28,9 @@ impl From<&Error> for WarningMessage {
}
DaemonError::Unexpected(_) => WarningMessage("Unknown error".to_string()),
DaemonError::Start(_) => WarningMessage("Daemon failed to start".to_string()),
DaemonError::ClientNotSupported => {
WarningMessage("Daemon client is not supported".to_string())
}
DaemonError::NoAnswer | DaemonError::Transport(..) => {
WarningMessage("Communication with Daemon failed".to_string())
}

View File

@ -18,9 +18,6 @@
//! and parsing responses
//!
#[cfg(windows)]
use uds_windows::UnixStream;
#[cfg(not(windows))]
use std::os::unix::net::UnixStream;
@ -70,7 +67,17 @@ impl JsonRPCClient {
self.timeout = timeout;
}
#[cfg(windows)]
pub fn send_request<S: Serialize + Debug, D: DeserializeOwned + Debug>(
&self,
method: &str,
params: Option<S>,
) -> Result<Response<D>, Error> {
Err(Error::NotSupported)
}
/// Sends a request to a client
#[cfg(not(windows))]
pub fn send_request<S: Serialize + Debug, D: DeserializeOwned + Debug>(
&self,
method: &str,
@ -185,6 +192,8 @@ pub enum Error {
NonceMismatch,
/// Response to a request had a jsonrpc field other than "2.0"
VersionMismatch,
/// unix socket communication is not supported.
NotSupported,
}
impl From<serde_json::Error> for Error {
@ -214,6 +223,7 @@ impl fmt::Display for Error {
Error::NoErrorOrResult => write!(f, "Malformed RPC response"),
Error::NonceMismatch => write!(f, "Nonce of response did not match nonce of request"),
Error::VersionMismatch => write!(f, "`jsonrpc` field set to non-\"2.0\""),
Error::NotSupported => write!(f, "unix socket communication is not supported"),
}
}
}
@ -239,6 +249,7 @@ impl From<Error> for super::DaemonError {
super::DaemonError::Transport(None, format!("transport: {}", e))
}
Error::NoErrorOrResult => super::DaemonError::NoAnswer,
Error::NotSupported => super::DaemonError::ClientNotSupported,
Error::Rpc(e) => super::DaemonError::Rpc(e.code, e.message),
}
}

View File

@ -24,6 +24,8 @@ pub enum DaemonError {
NoAnswer,
// Error at start up.
Start(StartupError),
// Error if the client is not supported.
ClientNotSupported,
}
impl std::fmt::Display for DaemonError {
@ -34,6 +36,7 @@ impl std::fmt::Display for DaemonError {
Self::Transport(kind, e) => write!(f, "Daemon transport error: [{:?}] {}", kind, e),
Self::Unexpected(e) => write!(f, "Daemon unexpected error: {}", e),
Self::Start(e) => write!(f, "Daemon did not start: {}", e),
Self::ClientNotSupported => write!(f, "Daemon communication is not supported"),
}
}
}

View File

@ -96,7 +96,8 @@ impl Loader {
Error::Config(_) => {
self.step = Step::Error(Box::new(e));
}
Error::Daemon(DaemonError::Transport(Some(ErrorKind::ConnectionRefused), _))
Error::Daemon(DaemonError::ClientNotSupported)
| Error::Daemon(DaemonError::Transport(Some(ErrorKind::ConnectionRefused), _))
| Error::Daemon(DaemonError::Transport(Some(ErrorKind::NotFound), _)) => {
self.step = Step::StartingDaemon;
self.daemon_started = true;