Make all code compile with latest indev crates

This commit is contained in:
NGnius (Graham) 2023-08-29 19:51:33 -04:00
parent 438d91f639
commit 9972ac7854
5 changed files with 149 additions and 48 deletions

136
backend-rs/Cargo.lock generated
View file

@ -250,7 +250,7 @@ name = "fantastic-rs"
version = "0.5.0" version = "0.5.0"
dependencies = [ dependencies = [
"log", "log",
"nrpc 0.6.0", "nrpc",
"prost", "prost",
"serde", "serde",
"serde_json", "serde_json",
@ -301,18 +301,95 @@ dependencies = [
"percent-encoding", "percent-encoding",
] ]
[[package]]
name = "futures"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.28" version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
[[package]]
name = "futures-executor"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-io"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
[[package]]
name = "futures-macro"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.18",
]
[[package]] [[package]]
name = "futures-sink" name = "futures-sink"
version = "0.3.28" version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e"
[[package]]
name = "futures-task"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
[[package]]
name = "futures-util"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-macro",
"futures-sink",
"futures-task",
"memchr",
"pin-project-lite",
"pin-utils",
"slab",
]
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.14.7" version = "0.14.7"
@ -520,6 +597,12 @@ dependencies = [
"logos-codegen", "logos-codegen",
] ]
[[package]]
name = "memchr"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76fc44e2588d5b436dbc3c6cf62aef290f90dab6235744a93dfe1cc18f451e2c"
[[package]] [[package]]
name = "miette" name = "miette"
version = "5.9.0" version = "5.9.0"
@ -571,29 +654,19 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
[[package]] [[package]]
name = "nrpc" name = "nrpc"
version = "0.6.0" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f41caeb65399490c6f68ab2527a833d6f2e9b0d7d5ffc4b062f1484b3fa61cd"
dependencies = [
"async-trait",
"bytes",
"prost",
]
[[package]]
name = "nrpc"
version = "0.7.0"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bytes", "bytes",
"futures",
"prost", "prost",
] ]
[[package]] [[package]]
name = "nrpc-build" name = "nrpc-build"
version = "0.7.0" version = "0.10.0"
dependencies = [ dependencies = [
"nrpc 0.7.0", "nrpc",
"prettyplease 0.2.6", "prettyplease 0.2.6",
"proc-macro2", "proc-macro2",
"prost-build", "prost-build",
@ -679,6 +752,12 @@ version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.27" version = "0.3.27"
@ -855,9 +934,9 @@ dependencies = [
[[package]] [[package]]
name = "ratchet_core" name = "ratchet_core"
version = "0.3.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854bf6632d9f5c7fa7f77cbc332f2b0a8dfb2acc36c3f351fc36bf40f2759728" checksum = "faed301a9f297e8cd3617a2bc79ed17eefa88d5873ed08517c96628b48d1f386"
dependencies = [ dependencies = [
"base64", "base64",
"bitflags", "bitflags",
@ -879,9 +958,9 @@ dependencies = [
[[package]] [[package]]
name = "ratchet_deflate" name = "ratchet_deflate"
version = "0.3.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0b144cb23a76d810b25737f4b87943fdfd7772b423bdc15c2b3820849207adc" checksum = "77238362df52f64482e0bd1c413d2d3d0e20052056ba4d88918ef2e962c86f11"
dependencies = [ dependencies = [
"bytes", "bytes",
"flate2", "flate2",
@ -893,9 +972,9 @@ dependencies = [
[[package]] [[package]]
name = "ratchet_ext" name = "ratchet_ext"
version = "0.3.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67f97bb0776d195720319a1e9f08fa343fe3f9f0b7ebf9d97d5926ce50b8e1ad" checksum = "35f5bf3bd015a94b77730229e895e03af945627984ee5c4f95d40fd9227ea36b"
dependencies = [ dependencies = [
"bytes", "bytes",
"http", "http",
@ -904,9 +983,9 @@ dependencies = [
[[package]] [[package]]
name = "ratchet_rs" name = "ratchet_rs"
version = "0.3.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7dba456fc23026b46ce0936d109ce3e73b4a592baf0dda0f83d49886c5e5f83" checksum = "62d326d7cd4227a7f58b36c1efb16b348f7e2e43e1d1ef032e9b094ff6cec583"
dependencies = [ dependencies = [
"ratchet_core", "ratchet_core",
"ratchet_deflate", "ratchet_deflate",
@ -1057,6 +1136,15 @@ dependencies = [
"time", "time",
] ]
[[package]]
name = "slab"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.10.0" version = "1.10.0"
@ -1279,7 +1367,7 @@ dependencies = [
"bytes", "bytes",
"gettext-ng", "gettext-ng",
"log", "log",
"nrpc 0.6.0", "nrpc",
"prost", "prost",
"ratchet_rs", "ratchet_rs",
"tokio", "tokio",

View file

@ -8,7 +8,7 @@ usdpl-back = { version = "0.11", features = ["blocking"], path = "../../usdpl-rs
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
nrpc = "0.6" nrpc = { version = "0.10", path = "../../nRPC/nrpc" }
prost = "0.11" prost = "0.11"
tokio = { version = "1", features = ["sync"] } tokio = { version = "1", features = ["sync"] }

View file

@ -19,17 +19,17 @@ impl FanService {
} }
#[usdpl_back::nrpc::_helpers::async_trait::async_trait] #[usdpl_back::nrpc::_helpers::async_trait::async_trait]
impl IFan for FanService { impl<'a> IFan<'a> for FanService {
async fn echo( async fn echo(
&mut self, &mut self,
input: EchoMessage, input: EchoMessage,
) -> Result<EchoMessage, Box<dyn std::error::Error>> { ) -> Result<EchoMessage, Box<dyn std::error::Error + Send>> {
Ok(input) Ok(input)
} }
async fn hello( async fn hello(
&mut self, &mut self,
input: NameMessage, input: NameMessage,
) -> Result<HelloResponse, Box<dyn std::error::Error>> { ) -> Result<HelloResponse, Box<dyn std::error::Error + Send>> {
Ok(HelloResponse { Ok(HelloResponse {
phrase: format!("Hello {}", input.name) phrase: format!("Hello {}", input.name)
}) })
@ -37,7 +37,7 @@ impl IFan for FanService {
async fn version( async fn version(
&mut self, &mut self,
_input: Empty, _input: Empty,
) -> Result<VersionMessage, Box<dyn std::error::Error>> { ) -> Result<VersionMessage, Box<dyn std::error::Error + Send>> {
Ok( Ok(
VersionMessage { VersionMessage {
major: 0, major: 0,
@ -50,7 +50,7 @@ impl IFan for FanService {
async fn version_str( async fn version_str(
&mut self, &mut self,
_input: Empty, _input: Empty,
) -> Result<VersionDisplayMessage, Box<dyn std::error::Error>> { ) -> Result<VersionDisplayMessage, Box<dyn std::error::Error + Send>> {
Ok( Ok(
VersionDisplayMessage { VersionDisplayMessage {
display: VERSION.to_owned(), display: VERSION.to_owned(),
@ -60,7 +60,7 @@ impl IFan for FanService {
async fn name( async fn name(
&mut self, &mut self,
_input: Empty, _input: Empty,
) -> Result<NameMessage, Box<dyn std::error::Error>> { ) -> Result<NameMessage, Box<dyn std::error::Error + Send>> {
Ok( Ok(
NameMessage { NameMessage {
name: NAME.to_string(), name: NAME.to_string(),
@ -70,30 +70,30 @@ impl IFan for FanService {
async fn get_fan_rpm( async fn get_fan_rpm(
&mut self, &mut self,
_input: Empty, _input: Empty,
) -> Result<RpmMessage, Box<dyn std::error::Error>> { ) -> Result<RpmMessage, Box<dyn std::error::Error + Send>> {
if let Some(rpm) = crate::sys::read_fan() { if let Some(rpm) = crate::sys::read_fan() {
log::debug!("get_fan_rpm() success: {}", rpm); log::debug!("get_fan_rpm() success: {}", rpm);
Ok(RpmMessage { rpm: rpm as u32 }) Ok(RpmMessage { rpm: rpm as u32 })
} else { } else {
Err("Failed to read fan speed".into()) Err(Box::<dyn std::error::Error + Send + Sync>::from("Failed to read fan speed"))
} }
} }
async fn get_temperature( async fn get_temperature(
&mut self, &mut self,
_input: Empty, _input: Empty,
) -> Result<TemperatureMessage, Box<dyn std::error::Error>>{ ) -> Result<TemperatureMessage, Box<dyn std::error::Error + Send>>{
if let Some(temperature) = crate::sys::read_thermal_zone(0) { if let Some(temperature) = crate::sys::read_thermal_zone(0) {
let real_temp = temperature as f64 / 1000.0; let real_temp = temperature as f64 / 1000.0;
log::debug!("get_temperature() success: {}", real_temp); log::debug!("get_temperature() success: {}", real_temp);
Ok(TemperatureMessage { temperature: real_temp }) Ok(TemperatureMessage { temperature: real_temp })
} else { } else {
Err("get_temperature failed to read thermal zone 0".into()) Err(Box::<dyn std::error::Error + Send + Sync>::from("get_temperature failed to read thermal zone 0"))
} }
} }
async fn set_enable( async fn set_enable(
&mut self, &mut self,
input: EnablementMessage, input: EnablementMessage,
) -> Result<EnablementMessage, Box<dyn std::error::Error>>{ ) -> Result<EnablementMessage, Box<dyn std::error::Error + Send>>{
let mut settings = self.ctrl.settings().write().await; let mut settings = self.ctrl.settings().write().await;
if settings.enable != input.is_enabled { if settings.enable != input.is_enabled {
let mut state = self.ctrl.state().write().await; let mut state = self.ctrl.state().write().await;
@ -106,7 +106,7 @@ impl IFan for FanService {
async fn get_enable( async fn get_enable(
&mut self, &mut self,
_input: Empty, _input: Empty,
) -> Result<EnablementMessage, Box<dyn std::error::Error>>{ ) -> Result<EnablementMessage, Box<dyn std::error::Error + Send>>{
let is_enabled = self.ctrl.settings().read().await.enable; let is_enabled = self.ctrl.settings().read().await.enable;
log::debug!("get_enable() success"); log::debug!("get_enable() success");
Ok(EnablementMessage { is_enabled }) Ok(EnablementMessage { is_enabled })
@ -114,7 +114,7 @@ impl IFan for FanService {
async fn set_interpolate( async fn set_interpolate(
&mut self, &mut self,
input: EnablementMessage, input: EnablementMessage,
) -> Result<EnablementMessage, Box<dyn std::error::Error>>{ ) -> Result<EnablementMessage, Box<dyn std::error::Error + Send>>{
let mut settings = self.ctrl.settings().write().await; let mut settings = self.ctrl.settings().write().await;
if settings.interpolate != input.is_enabled { if settings.interpolate != input.is_enabled {
let mut state = self.ctrl.state().write().await; let mut state = self.ctrl.state().write().await;
@ -127,7 +127,7 @@ impl IFan for FanService {
async fn get_interpolate( async fn get_interpolate(
&mut self, &mut self,
_input: Empty, _input: Empty,
) -> Result<EnablementMessage, Box<dyn std::error::Error>>{ ) -> Result<EnablementMessage, Box<dyn std::error::Error + Send>>{
let is_enabled = self.ctrl.settings().read().await.interpolate; let is_enabled = self.ctrl.settings().read().await.interpolate;
log::debug!("get_interpolate() success"); log::debug!("get_interpolate() success");
Ok(EnablementMessage { is_enabled }) Ok(EnablementMessage { is_enabled })
@ -135,7 +135,7 @@ impl IFan for FanService {
async fn get_curve_x( async fn get_curve_x(
&mut self, &mut self,
_input: Empty, _input: Empty,
) -> Result<CurveMessageX, Box<dyn std::error::Error>>{ ) -> Result<CurveMessageX, Box<dyn std::error::Error + Send>>{
let settings = self.ctrl.settings().read().await; let settings = self.ctrl.settings().read().await;
let x = settings.curve.iter().map(|p| p.x).collect(); let x = settings.curve.iter().map(|p| p.x).collect();
log::debug!("get_curve_x() success"); log::debug!("get_curve_x() success");
@ -144,7 +144,7 @@ impl IFan for FanService {
async fn get_curve_y( async fn get_curve_y(
&mut self, &mut self,
_input: Empty, _input: Empty,
) -> Result<CurveMessageY, Box<dyn std::error::Error>>{ ) -> Result<CurveMessageY, Box<dyn std::error::Error + Send>>{
let settings = self.ctrl.settings().read().await; let settings = self.ctrl.settings().read().await;
let y = settings.curve.iter().map(|p| p.y).collect(); let y = settings.curve.iter().map(|p| p.y).collect();
log::debug!("get_curve_x() success"); log::debug!("get_curve_x() success");
@ -153,7 +153,7 @@ impl IFan for FanService {
async fn add_curve_point( async fn add_curve_point(
&mut self, &mut self,
point: GraphPoint, point: GraphPoint,
) -> Result<Empty, Box<dyn std::error::Error>>{ ) -> Result<Empty, Box<dyn std::error::Error + Send>>{
let mut settings = self.ctrl.settings().write().await; let mut settings = self.ctrl.settings().write().await;
settings.curve.push(super::datastructs::GraphPoint { settings.curve.push(super::datastructs::GraphPoint {
x: point.x, x: point.x,
@ -167,7 +167,7 @@ impl IFan for FanService {
async fn remove_curve_point( async fn remove_curve_point(
&mut self, &mut self,
input: IndexMessage, input: IndexMessage,
) -> Result<Empty, Box<dyn std::error::Error>>{ ) -> Result<Empty, Box<dyn std::error::Error + Send>>{
let mut settings = self.ctrl.settings().write().await; let mut settings = self.ctrl.settings().write().await;
let i = input.index as usize; let i = input.index as usize;
if settings.curve.len() < i { if settings.curve.len() < i {

21
src/rust/Cargo.lock generated
View file

@ -272,14 +272,15 @@ dependencies = [
[[package]] [[package]]
name = "gloo-net" name = "gloo-net"
version = "0.2.6" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9902a044653b26b99f7e3693a42f171312d9be8b26b5697bd1e43ad1f8a35e10" checksum = "a66b4e3c7d9ed8d315fd6b97c8b1f74a7c6ecbbc2320e65ae7ed38b7068cc620"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"gloo-utils", "gloo-utils",
"http",
"js-sys", "js-sys",
"pin-project", "pin-project",
"serde", "serde",
@ -321,6 +322,17 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
[[package]]
name = "http"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482"
dependencies = [
"bytes",
"fnv",
"itoa",
]
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.9.3" version = "1.9.3"
@ -468,16 +480,17 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
[[package]] [[package]]
name = "nrpc" name = "nrpc"
version = "0.7.0" version = "0.10.0"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bytes", "bytes",
"futures",
"prost", "prost",
] ]
[[package]] [[package]]
name = "nrpc-build" name = "nrpc-build"
version = "0.7.0" version = "0.10.0"
dependencies = [ dependencies = [
"nrpc", "nrpc",
"prettyplease 0.2.9", "prettyplease 0.2.9",

View file

@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"]
[dependencies] [dependencies]
usdpl-front = { version = "0.11", path = "../../../usdpl-rs/usdpl-front"} usdpl-front = { version = "0.11", path = "../../../usdpl-rs/usdpl-front"}
nrpc = { version = "0.7", path = "../../../nRPC/nrpc" } nrpc = { version = "0.10", path = "../../../nRPC/nrpc", default-features = false }
prost = "0.11" prost = "0.11"
[build-dependencies] [build-dependencies]