Skip to content

Commit

Permalink
fix: CI and various other updates (rust-lang#83)
Browse files Browse the repository at this point in the history
- cargo clippy fixes
- bump MSRV
- License syntax
- author email address
  • Loading branch information
haraldh authored Jul 27, 2023
2 parents a6464da + d057506 commit 3def61c
Show file tree
Hide file tree
Showing 24 changed files with 60 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
windows-latest
]
version:
- 1.47.0
- 1.63.0
- stable
- nightly

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "example"
version = "3.0.2"
authors = ["Harald Hoyer <harald@redhat.com>"]
authors = ["Harald Hoyer <harald@hoyer.xyz>"]
edition = "2018"
publish = false

Expand Down
9 changes: 4 additions & 5 deletions examples/example/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion examples/more/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "more"
version = "2.0.2"
authors = ["Harald Hoyer <harald@redhat.com>"]
authors = ["Harald Hoyer <harald@hoyer.xyz>"]
build = "build.rs"
edition = "2018"
publish = false
Expand Down
10 changes: 5 additions & 5 deletions examples/more/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion examples/ping/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ping"
version = "2.0.2"
authors = ["Harald Hoyer <harald@redhat.com>"]
authors = ["Harald Hoyer <harald@hoyer.xyz>"]
build = "build.rs"
edition = "2018"
publish = false
Expand Down
15 changes: 7 additions & 8 deletions examples/ping/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion varlink-certification/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "varlink-certification"
version = "2.0.4"
authors = ["Harald Hoyer <harald@redhat.com>"]
authors = ["Harald Hoyer <harald@hoyer.xyz>"]
build = "build.rs"
edition = "2018"
publish = false
Expand Down
10 changes: 5 additions & 5 deletions varlink-certification/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions varlink-certification/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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());
}
4 changes: 2 additions & 2 deletions varlink-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "varlink-cli"
version = "4.5.3"
authors = ["Harald Hoyer <harald@redhat.com>"]
authors = ["Harald Hoyer <harald@hoyer.xyz>"]
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"
Expand Down
6 changes: 3 additions & 3 deletions varlink-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn varlink_help(
}
};

if interface.find('.') == None {
if interface.find('.').is_none() {
return Err(format!("Invalid address {}", url).into());
}

Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions varlink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "varlink"
version = "11.0.1"
authors = ["Harald Hoyer <harald@redhat.com>"]
authors = ["Harald Hoyer <harald@hoyer.xyz>"]
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"
Expand Down
2 changes: 1 addition & 1 deletion varlink/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn varlink_connect<S: ?Sized + AsRef<str>>(address: &S) -> Result<(Box<dyn S

if let Some(addr) = new_address.strip_prefix("tcp:") {
Ok((
Box::new(TcpStream::connect(&addr).map_err(map_context!())?),
Box::new(TcpStream::connect(addr).map_err(map_context!())?),
new_address,
))
} else if let Some(addr) = new_address.strip_prefix("unix:") {
Expand Down
2 changes: 1 addition & 1 deletion varlink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ where
conn.writer = self.writer.take();
}
}
if reply.error != None {
if reply.error.is_some() {
return Err(context!(ErrorKind::from(reply)).into());
}

Expand Down
9 changes: 3 additions & 6 deletions varlink/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@ fn activation_listener() -> Option<usize> {
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);
}
}

Expand Down Expand Up @@ -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:") {
Expand Down
2 changes: 1 addition & 1 deletion varlink/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions varlink_derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "varlink_derive"
version = "10.1.0"
authors = ["Harald Hoyer <harald@redhat.com>"]
authors = ["Harald Hoyer <harald@hoyer.xyz>"]
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"
Expand Down
4 changes: 2 additions & 2 deletions varlink_generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "varlink_generator"
version = "10.1.0"
authors = ["Harald Hoyer <harald@redhat.com>"]
authors = ["Harald Hoyer <harald@hoyer.xyz>"]
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"
Expand Down
4 changes: 2 additions & 2 deletions varlink_generator/tests/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ fn test_generate() {
1,
))
.unwrap();
return false;
false
} else {
return true;
true
}
}

Expand Down
4 changes: 2 additions & 2 deletions varlink_parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "varlink_parser"
version = "4.2.0"
authors = ["Harald Hoyer <harald@redhat.com>"]
authors = ["Harald Hoyer <harald@hoyer.xyz>"]
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"
Expand Down
6 changes: 3 additions & 3 deletions varlink_parser/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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(),
"\
Expand Down Expand Up @@ -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(),
"\
Expand Down
4 changes: 2 additions & 2 deletions varlink_stdinterfaces/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "varlink_stdinterfaces"
version = "11.0.2"
authors = ["Harald Hoyer <harald@redhat.com>"]
authors = ["Harald Hoyer <harald@hoyer.xyz>"]
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"
Expand Down

0 comments on commit 3def61c

Please sign in to comment.