From 0cb784f9f98cdc20699c5cc7d9579560e866f7a6 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 27 Jul 2023 15:26:58 +0200 Subject: [PATCH 1/4] fix: cargo clippy Signed-off-by: Harald Hoyer --- examples/example/src/test.rs | 9 ++++----- examples/more/src/test.rs | 10 +++++----- examples/ping/src/test.rs | 15 +++++++-------- varlink-certification/src/main.rs | 10 +++++----- varlink-certification/src/test.rs | 12 ++++++------ varlink-cli/src/main.rs | 6 +++--- varlink/src/client.rs | 2 +- varlink/src/lib.rs | 2 +- varlink/src/server.rs | 9 +++------ varlink/src/test.rs | 2 +- varlink_generator/tests/generator.rs | 4 ++-- varlink_parser/src/test.rs | 6 +++--- 12 files changed, 41 insertions(+), 46 deletions(-) diff --git a/examples/example/src/test.rs b/examples/example/src/test.rs index d5dc2e1cbe96f..97c190be46750 100644 --- a/examples/example/src/test.rs +++ b/examples/example/src/test.rs @@ -19,11 +19,10 @@ fn run_self_test(address: &'static str) -> Result<()> { if let Err(e) = ret { panic!("error: {}", e); } - if let Err(_) = child.join() { - Err(format!("Error joining thread").into()) - } else { - Ok(()) - } + child + .join() + .map_err(|_| "Error joining thread".to_string())?; + Ok(()) } #[test] diff --git a/examples/more/src/test.rs b/examples/more/src/test.rs index db3445320f371..fe5cd19ea1506 100644 --- a/examples/more/src/test.rs +++ b/examples/more/src/test.rs @@ -22,11 +22,11 @@ fn run_self_test(address: String) -> Result<()> { if let Err(e) = ret { panic!("error: {}", e); } - if let Err(_) = child.join() { - Err("Error joining thread".into()) - } else { - Ok(()) - } + + child + .join() + .map_err(|_| "Error joining thread".to_string())?; + Ok(()) } #[test] diff --git a/examples/ping/src/test.rs b/examples/ping/src/test.rs index 3b07721829d4b..a7af25b4ee65c 100644 --- a/examples/ping/src/test.rs +++ b/examples/ping/src/test.rs @@ -42,7 +42,7 @@ fn run_self_test(address: String, multiplex: bool) -> Result<()> { let b = &br[10..20]; let c = &br[20..]; - for i in vec![a, b, c] { + for i in &[a, b, c] { assert!(writer.write_all(i).is_ok()); assert!(writer.flush().is_ok()); thread::sleep(time::Duration::from_millis(500)); @@ -86,7 +86,7 @@ fn run_self_test(address: String, multiplex: bool) -> Result<()> { let b = &br[10..20]; let c = &br[20..]; - for i in vec![a, b, c] { + for i in &[a, b, c] { assert!(writer.write_all(i).is_ok()); assert!(writer.flush().is_ok()); thread::sleep(time::Duration::from_millis(500)); @@ -115,7 +115,7 @@ fn run_self_test(address: String, multiplex: bool) -> Result<()> { let b = &br[10..20]; let c = &br[20..]; - for i in vec![a, b, c] { + for i in &[a, b, c] { assert!(writer.write_all(i).is_ok()); assert!(writer.flush().is_ok()); thread::sleep(time::Duration::from_millis(500)); @@ -146,11 +146,10 @@ fn run_self_test(address: String, multiplex: bool) -> Result<()> { } eprintln!("run_client finished"); - if let Err(_) = child.join() { - Err(format!("Error joining thread").into()) - } else { - Ok(()) - } + child + .join() + .map_err(|_| "Error joining thread".to_string())?; + Ok(()) } #[cfg(target_os = "not_working")] diff --git a/varlink-certification/src/main.rs b/varlink-certification/src/main.rs index 0e1ab38a35827..364e2c5665372 100644 --- a/varlink-certification/src/main.rs +++ b/varlink-certification/src/main.rs @@ -374,12 +374,12 @@ impl org_varlink_certification::VarlinkInterface for CertInterface { | Some(&varlink::Request { oneway: Some(true), .. }) => false, - Some(&varlink::Request { - method: ref m, - parameters: ref p, + Some(varlink::Request { + method: m, + parameters: p, .. }) if m == "org.varlink.certification.Start" - && (*p == None + && (p.is_none() || *p == Some(serde_json::Value::Object(serde_json::Map::new()))) => { true @@ -717,7 +717,7 @@ impl ClientIds { let pop = match self.lifetimes.front() { None => false, - Some(&(ref instant, ref client_id)) => { + Some((instant, client_id)) => { if instant.elapsed().as_secs() > self.max_lifetime { self.contexts.remove(client_id); true diff --git a/varlink-certification/src/test.rs b/varlink-certification/src/test.rs index 463a8ea163c0c..0cd4c96ce164a 100644 --- a/varlink-certification/src/test.rs +++ b/varlink-certification/src/test.rs @@ -23,11 +23,11 @@ fn run_self_test(address: String) -> Result<()> { if let Err(e) = ret { panic!("error: {:?}", e); } - if let Err(_) = child.join() { - Err(format!("Error joining thread").into()) - } else { - Ok(()) - } + + child + .join() + .map_err(|_| "Error joining thread".to_string())?; + Ok(()) } #[test] @@ -48,5 +48,5 @@ fn test_tcp() -> Result<()> { #[test] fn test_wrong_address_1() { - assert!(crate::run_server("tcpd:0.0.0.0:12345".into(), 1).is_err()); + assert!(crate::run_server("tcpd:0.0.0.0:12345", 1).is_err()); } diff --git a/varlink-cli/src/main.rs b/varlink-cli/src/main.rs index bd17d815bcb42..7923a38ca1d99 100644 --- a/varlink-cli/src/main.rs +++ b/varlink-cli/src/main.rs @@ -144,7 +144,7 @@ fn varlink_help( } }; - if interface.find('.') == None { + if interface.find('.').is_none() { return Err(format!("Invalid address {}", url).into()); } @@ -213,14 +213,14 @@ fn varlink_call( if let Some(del) = url.rfind('/') { address = &url[0..del]; method = &url[(del + 1)..]; - if method.find('.') == None { + if method.find('.').is_none() { return Err(format!("Invalid address {}", url).into()); } } else { if let Some(del) = url.rfind('.') { interface = &url[0..del]; method = url; - if method.find('.') == None { + if method.find('.').is_none() { return Err(format!("Invalid address {}", url).into()); } } else { diff --git a/varlink/src/client.rs b/varlink/src/client.rs index 4f9054bd22168..026acf5280b3d 100644 --- a/varlink/src/client.rs +++ b/varlink/src/client.rs @@ -25,7 +25,7 @@ pub fn varlink_connect>(address: &S) -> Result<(Box Option { return Some(3); } - let fdnames = match env::var("LISTEN_FDNAMES") { - Ok(n) => n, - _ => return None, - }; + let fdnames = env::var("LISTEN_FDNAMES").ok()?; for (i, v) in fdnames.split(':').enumerate() { if v == "varlink" { - return Some(3 + i as usize); + return Some(3 + i); } } @@ -134,7 +131,7 @@ impl Listener { if let Some(addr) = address.strip_prefix("tcp:") { Ok(Listener::TCP( - Some(TcpListener::bind(&addr).map_err(map_context!())?), + Some(TcpListener::bind(addr).map_err(map_context!())?), false, )) } else if let Some(addr) = address.strip_prefix("unix:") { diff --git a/varlink/src/test.rs b/varlink/src/test.rs index 361112e31d700..ea6302d8cf050 100644 --- a/varlink/src/test.rs +++ b/varlink/src/test.rs @@ -172,7 +172,7 @@ fn test_handle() -> Result<()> { panic!("Unexpected handle return value {}", iface); } (v, None) => { - if v.len() == 0 { + if v.is_empty() { break; } //eprintln!("unhandled: {}", String::from_utf8_lossy(&v)); diff --git a/varlink_generator/tests/generator.rs b/varlink_generator/tests/generator.rs index cd84144a2772e..6c87d7f08d12b 100644 --- a/varlink_generator/tests/generator.rs +++ b/varlink_generator/tests/generator.rs @@ -27,9 +27,9 @@ fn test_generate() { 1, )) .unwrap(); - return false; + false } else { - return true; + true } } diff --git a/varlink_parser/src/test.rs b/varlink_parser/src/test.rs index 8136f1fdb49e5..96bd58aaec4d4 100644 --- a/varlink_parser/src/test.rs +++ b/varlink_parser/src/test.rs @@ -45,7 +45,7 @@ error InvalidParameter (parameter: string) " ); assert_eq!( - v.methods.get("GetInterfaceDescription".into()).unwrap().doc, + v.methods.get("GetInterfaceDescription").unwrap().doc, "# Get the description of an interface that is implemented by this service." ); //println!("{}", v.to_string()); @@ -109,7 +109,7 @@ error ErrorFoo (a: (b: bool, c: int), foo: TypeFoo) ) .unwrap(); assert_eq!(v.name, "org.example.complex"); - println!("{}", v.to_string()); + println!("{}", v); assert_eq!( v.to_string(), "\ @@ -160,7 +160,7 @@ error ErrorFoo1 (a: (foo: bool, bar: int, baz: (a: int, b: int), b: (beee: int)) .unwrap(); assert_eq!(v.name, "org.example.format"); println!("{}", v.get_oneline()); - println!("{}", v.to_string()); + println!("{}", v); assert_eq!( v.to_string(), "\ From d646190454ca67350b2dacaeb974a9e2561edb7c Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 27 Jul 2023 15:57:30 +0200 Subject: [PATCH 2/4] fix: bump MSRV Signed-off-by: Harald Hoyer --- .github/workflows/CI.yml | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c3d35fdfd17a2..8b7c87ec1b6dc 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -25,7 +25,7 @@ jobs: windows-latest ] version: - - 1.47.0 + - 1.63.0 - stable - nightly diff --git a/README.md b/README.md index 64cbeeccfbff8..6da029aea3d42 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ [![Crate](https://img.shields.io/crates/v/varlink.svg)](https://crates.io/crates/varlink) [![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/varlink/) [![dependency status](https://deps.rs/repo/github/varlink/rust/status.svg)](https://deps.rs/repo/github/varlink/rust) -![Rust Version 1.47+](https://img.shields.io/badge/rustc-v1.47%2B-blue.svg) +![Rust Version 1.63+](https://img.shields.io/badge/rustc-v1.63%2B-blue.svg) See http://varlink.org for more information about varlink. ## Example usage Look into the examples directory. ```build.rs``` contains the magic, which will build rust bindings for the varlink interface definition file. - +Or use `varlink_derive` to generate the bindings at compile time. ## More Info * [Git Repo](https://github.com/varlink/rust) From 7a7ea9cfa1a320c2afff753d1894d55ef6000695 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 27 Jul 2023 16:28:45 +0200 Subject: [PATCH 3/4] chore: fix Licenses to SPDX syntax Signed-off-by: Harald Hoyer --- varlink-cli/Cargo.toml | 2 +- varlink/Cargo.toml | 2 +- varlink_derive/Cargo.toml | 2 +- varlink_generator/Cargo.toml | 2 +- varlink_parser/Cargo.toml | 2 +- varlink_stdinterfaces/Cargo.toml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/varlink-cli/Cargo.toml b/varlink-cli/Cargo.toml index fc7251dbba0ad..0c80d96e029d8 100644 --- a/varlink-cli/Cargo.toml +++ b/varlink-cli/Cargo.toml @@ -4,7 +4,7 @@ version = "4.5.3" authors = ["Harald Hoyer "] edition = "2018" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" documentation = "https://github.com/varlink/rust/blob/master/varlink/README.md" homepage = "https://github.com/varlink/rust/blob/master/varlink-cli" repository = "https://github.com/varlink/rust" diff --git a/varlink/Cargo.toml b/varlink/Cargo.toml index f58b09144c5ac..2f5a84864a97f 100644 --- a/varlink/Cargo.toml +++ b/varlink/Cargo.toml @@ -4,7 +4,7 @@ version = "11.0.1" authors = ["Harald Hoyer "] edition = "2018" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" documentation = "https://github.com/varlink/rust/blob/master/varlink/README.md" homepage = "https://github.com/varlink/rust/blob/master/varlink" repository = "https://github.com/varlink/rust" diff --git a/varlink_derive/Cargo.toml b/varlink_derive/Cargo.toml index 5223d81a71cc4..ee83d28d022ad 100644 --- a/varlink_derive/Cargo.toml +++ b/varlink_derive/Cargo.toml @@ -3,7 +3,7 @@ name = "varlink_derive" version = "10.1.0" authors = ["Harald Hoyer "] edition = "2018" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" documentation = "https://github.com/varlink/rust/blob/master/varlink/README.md" homepage = "https://github.com/varlink/rust/blob/master/varlink_derive" repository = "https://github.com/varlink/rust" diff --git a/varlink_generator/Cargo.toml b/varlink_generator/Cargo.toml index 731ad83016c3a..8637d293457ee 100644 --- a/varlink_generator/Cargo.toml +++ b/varlink_generator/Cargo.toml @@ -4,7 +4,7 @@ version = "10.1.0" authors = ["Harald Hoyer "] edition = "2018" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" documentation = "https://github.com/varlink/rust/blob/master/varlink/README.md" homepage = "https://github.com/varlink/rust/blob/master/varlink_generator" repository = "https://github.com/varlink/rust" diff --git a/varlink_parser/Cargo.toml b/varlink_parser/Cargo.toml index 6f9be0e68d7f9..fced33901fd65 100644 --- a/varlink_parser/Cargo.toml +++ b/varlink_parser/Cargo.toml @@ -4,7 +4,7 @@ version = "4.2.0" authors = ["Harald Hoyer "] edition = "2018" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" documentation = "https://docs.rs/varlink_parser/" homepage = "https://github.com/varlink/rust/blob/master/varlink_parser" repository = "https://github.com/varlink/rust" diff --git a/varlink_stdinterfaces/Cargo.toml b/varlink_stdinterfaces/Cargo.toml index 9a45339b47b7e..2bc2176e803b4 100644 --- a/varlink_stdinterfaces/Cargo.toml +++ b/varlink_stdinterfaces/Cargo.toml @@ -4,7 +4,7 @@ version = "11.0.2" authors = ["Harald Hoyer "] edition = "2018" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" documentation = "https://github.com/varlink/rust/blob/master/varlink/README.md" homepage = "https://github.com/varlink/rust/blob/master/varlink_stdinterfaces" repository = "https://github.com/varlink/rust" From d0575067fb67461343f184bfe52a983be419a277 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 27 Jul 2023 16:30:29 +0200 Subject: [PATCH 4/4] chore: change author email address Signed-off-by: Harald Hoyer --- examples/example/Cargo.toml | 2 +- examples/more/Cargo.toml | 2 +- examples/ping/Cargo.toml | 2 +- varlink-certification/Cargo.toml | 2 +- varlink-cli/Cargo.toml | 2 +- varlink/Cargo.toml | 2 +- varlink_derive/Cargo.toml | 2 +- varlink_generator/Cargo.toml | 2 +- varlink_parser/Cargo.toml | 2 +- varlink_stdinterfaces/Cargo.toml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/example/Cargo.toml b/examples/example/Cargo.toml index f8f1f22b16e5b..015246541fd53 100644 --- a/examples/example/Cargo.toml +++ b/examples/example/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "example" version = "3.0.2" -authors = ["Harald Hoyer "] +authors = ["Harald Hoyer "] edition = "2018" publish = false diff --git a/examples/more/Cargo.toml b/examples/more/Cargo.toml index f20174f19f525..e8ee48a0cd6ac 100644 --- a/examples/more/Cargo.toml +++ b/examples/more/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "more" version = "2.0.2" -authors = ["Harald Hoyer "] +authors = ["Harald Hoyer "] build = "build.rs" edition = "2018" publish = false diff --git a/examples/ping/Cargo.toml b/examples/ping/Cargo.toml index 6fde345e72052..690d91c3f8ed8 100644 --- a/examples/ping/Cargo.toml +++ b/examples/ping/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ping" version = "2.0.2" -authors = ["Harald Hoyer "] +authors = ["Harald Hoyer "] build = "build.rs" edition = "2018" publish = false diff --git a/varlink-certification/Cargo.toml b/varlink-certification/Cargo.toml index d9bb327f81a88..b312250ea011c 100644 --- a/varlink-certification/Cargo.toml +++ b/varlink-certification/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "varlink-certification" version = "2.0.4" -authors = ["Harald Hoyer "] +authors = ["Harald Hoyer "] build = "build.rs" edition = "2018" publish = false diff --git a/varlink-cli/Cargo.toml b/varlink-cli/Cargo.toml index 0c80d96e029d8..f36173fc44734 100644 --- a/varlink-cli/Cargo.toml +++ b/varlink-cli/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "varlink-cli" version = "4.5.3" -authors = ["Harald Hoyer "] +authors = ["Harald Hoyer "] edition = "2018" license = "MIT OR Apache-2.0" diff --git a/varlink/Cargo.toml b/varlink/Cargo.toml index 2f5a84864a97f..22559dc2c98b3 100644 --- a/varlink/Cargo.toml +++ b/varlink/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "varlink" version = "11.0.1" -authors = ["Harald Hoyer "] +authors = ["Harald Hoyer "] edition = "2018" license = "MIT OR Apache-2.0" diff --git a/varlink_derive/Cargo.toml b/varlink_derive/Cargo.toml index ee83d28d022ad..90104d4c19ac5 100644 --- a/varlink_derive/Cargo.toml +++ b/varlink_derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "varlink_derive" version = "10.1.0" -authors = ["Harald Hoyer "] +authors = ["Harald Hoyer "] edition = "2018" license = "MIT OR Apache-2.0" documentation = "https://github.com/varlink/rust/blob/master/varlink/README.md" diff --git a/varlink_generator/Cargo.toml b/varlink_generator/Cargo.toml index 8637d293457ee..8cd41a92f0e87 100644 --- a/varlink_generator/Cargo.toml +++ b/varlink_generator/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "varlink_generator" version = "10.1.0" -authors = ["Harald Hoyer "] +authors = ["Harald Hoyer "] edition = "2018" license = "MIT OR Apache-2.0" diff --git a/varlink_parser/Cargo.toml b/varlink_parser/Cargo.toml index fced33901fd65..3f25e92eb61ef 100644 --- a/varlink_parser/Cargo.toml +++ b/varlink_parser/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "varlink_parser" version = "4.2.0" -authors = ["Harald Hoyer "] +authors = ["Harald Hoyer "] edition = "2018" license = "MIT OR Apache-2.0" diff --git a/varlink_stdinterfaces/Cargo.toml b/varlink_stdinterfaces/Cargo.toml index 2bc2176e803b4..b689b3bb5c082 100644 --- a/varlink_stdinterfaces/Cargo.toml +++ b/varlink_stdinterfaces/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "varlink_stdinterfaces" version = "11.0.2" -authors = ["Harald Hoyer "] +authors = ["Harald Hoyer "] edition = "2018" license = "MIT OR Apache-2.0"