Skip to content

Commit dce7f5a

Browse files
authored
Merge pull request #18 from hug-dev/lints
Various lint fixes
2 parents 0fdae17 + 52c8259 commit dce7f5a

File tree

15 files changed

+32
-24
lines changed

15 files changed

+32
-24
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
runs-on: ubuntu-latest
2929
steps:
3030
- uses: actions/checkout@v1
31-
- run: cargo clippy
31+
- run: cargo clippy --all-targets --all-features -- -D clippy::all -D clippy::cargo
3232

3333
cross-testing-arm64-linux:
3434
name: Cross testing for the aarch64-unknown-linux-gnu target

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
--->
1717
# Contributing to `parsec-interface-rs`
1818

19-
Contributions to PARSEC need to follow the process below.
19+
Contributions to Parsec need to follow the process below.
2020

2121
* Contributions are done through GitHub pull-requests.
2222
* Contributors need to apply `rustfmt` and `clippy` to their Rust code.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ version = "0.6.0"
44
authors = ["Paul Howard <[email protected]>",
55
"Ionut Mihalcea <[email protected]>",
66
"Hugues de Valon <[email protected]>"]
7+
description = "Parsec interface library to communicate using the wire protocol"
8+
license = "Apache-2.0"
9+
repository = "https://github.com/parallaxsecond/parsec-interface-rs"
10+
readme = "README.md"
11+
keywords = ["parsec", "interface", "serialization"]
12+
categories = ["encoding"]
713
edition = "2018"
814

915
[build-dependencies]

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This Dockerfile is used by cross for cross-compilation and cross-testing of
2-
# PARSEC.
2+
# Parsec.
33

44
FROM rustembedded/cross:aarch64-unknown-linux-gnu-0.1.16
55

src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@
4343
unused_results,
4444
missing_copy_implementations
4545
)]
46-
//! # PARSEC Rust Interface
46+
// This one is hard to avoid.
47+
#![allow(clippy::multiple_crate_versions)]
48+
//! # Parsec Rust Interface
4749
//!
48-
//! The PARSEC Rust Interface provides methods to communicate easily with the PARSEC service using
50+
//! The Parsec Rust Interface provides methods to communicate easily with the Parsec service using
4951
//! the [wire protocol](https://github.com/docker/parsec/blob/master/docs/wire_protocol.md).
5052
//!
51-
//! ## For the PARSEC service
53+
//! ## For the Parsec service
5254
//!
53-
//! This library is used by the PARSEC service to:
55+
//! This library is used by the Parsec service to:
5456
//! * read from a stream a `Request` sent to the service with the `read_from_stream` method
5557
//! * use the `body_to_operation` method of the `Convert` trait on a converter to parse the request
5658
//! body into a `NativeOperation`
@@ -86,18 +88,18 @@
8688
//!response.write_to_stream(&mut stream).unwrap();
8789
//!```
8890
//!
89-
//! ## For the PARSEC Rust clients
91+
//! ## For the Parsec Rust clients
9092
//!
91-
//! This library is used by the PARSEC Rust clients to:
93+
//! This library is used by the Parsec Rust clients to:
9294
//! * use the `operation_to_body` method to serialize the `NativeOperation` to be sent as body of a
9395
//! `Request`
9496
//! * write it to the stream with the `write_to_stream` method.
9597
//!
96-
//! and after the operation has been executed by the PARSEC service:
98+
//! and after the operation has been executed by the Parsec service:
9799
//! * read from a stream the `Response` from the service with the `read_from_stream` method
98100
//! * use the `body_to_result` method to parse the result body into a `NativeResult`
99101
//!
100-
//! See the [PARSEC Test client](https://github.com/docker/parsec-client-test) as an example of a
102+
//! See the [Parsec Test client](https://github.com/docker/parsec-client-test) as an example of a
101103
//! Rust client.
102104
//!
103105
//! ### Example

src/operations_protobuf/convert_create_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ mod test {
115115
fn create_key_op_e2e() {
116116
let name = "test name".to_string();
117117
let op = OpCreateKey {
118-
key_name: name.clone(),
118+
key_name: name,
119119
key_attributes: get_key_attrs(),
120120
};
121121

src/operations_protobuf/convert_import_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ mod test {
122122
fn import_key_op_e2e() {
123123
let name = "test name".to_string();
124124
let op = OpImportKey {
125-
key_name: name.clone(),
125+
key_name: name,
126126
key_attributes: get_key_attrs(),
127127
key_data: vec![0x11, 0x22, 0x33],
128128
};

src/operations_protobuf/convert_list_opcodes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ mod test {
113113
let body = CONVERTER
114114
.operation_to_body(NativeOperation::ListOpcodes(list_opcodes))
115115
.expect("Failed to convert request");
116-
assert!(body.len() == 0);
116+
assert!(body.is_empty());
117117
}
118118

119119
#[test]

src/operations_protobuf/convert_list_providers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ mod test {
193193
let body = CONVERTER
194194
.operation_to_body(NativeOperation::ListProviders(list_providers))
195195
.expect("Failed to convert request");
196-
assert!(body.len() == 0);
196+
assert!(body.is_empty());
197197
}
198198

199199
#[test]

src/operations_protobuf/convert_ping.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ mod test {
8585
supp_version_min: 1,
8686
};
8787

88-
let proto: ResultPing = resp.into();
89-
assert!(proto.supp_version_maj == 1);
90-
assert!(proto.supp_version_min == 1);
88+
let proto: ResultPingProto = resp.try_into().unwrap();
89+
assert!(proto.supported_version_maj == 1);
90+
assert!(proto.supported_version_min == 1);
9191
}
9292

9393
#[test]
@@ -102,7 +102,7 @@ mod test {
102102
let body = CONVERTER
103103
.operation_to_body(NativeOperation::Ping(ping))
104104
.expect("Failed to convert request");
105-
assert!(body.len() == 0);
105+
assert!(body.is_empty());
106106
}
107107

108108
#[test]

src/operations_protobuf/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mod convert_list_providers;
2727
mod convert_list_opcodes;
2828

2929
#[rustfmt::skip]
30-
#[allow(unused_qualifications, missing_copy_implementations)]
30+
#[allow(unused_qualifications, missing_copy_implementations, clippy::pedantic)]
3131
mod generated_ops {
3232
// Include the Rust generated file in its own module.
3333
macro_rules! include_protobuf_as_module {

src/requests/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const MAGIC_NUMBER: u32 = 0x5EC0_A710;
3939
#[derive(FromPrimitive, PartialEq, Eq, Hash, Copy, Clone, Debug)]
4040
#[repr(u8)]
4141
pub enum ProviderID {
42-
/// Provider to use for core PARSEC operations.
42+
/// Provider to use for core Parsec operations.
4343
CoreProvider = 0,
4444
/// Provider using Mbed Crypto software library.
4545
MbedProvider = 1,

src/requests/request/request_header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl RawRequestHeader {
9393
if magic_number != MAGIC_NUMBER || hdr_size != REQUEST_HDR_SIZE {
9494
return Err(ResponseStatus::InvalidHeader);
9595
}
96-
let mut bytes = vec![0u8; usize::try_from(hdr_size)?];
96+
let mut bytes = vec![0_u8; usize::try_from(hdr_size)?];
9797
stream.read_exact(&mut bytes)?;
9898

9999
Ok(bincode::deserialize(&bytes)?)

src/requests/response/response_header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl RawResponseHeader {
8686
if magic_number != MAGIC_NUMBER || hdr_size != RESPONSE_HDR_SIZE {
8787
return Err(ResponseStatus::InvalidHeader);
8888
}
89-
let mut bytes = vec![0u8; usize::try_from(hdr_size)?];
89+
let mut bytes = vec![0_u8; usize::try_from(hdr_size)?];
9090
stream.read_exact(&mut bytes)?;
9191

9292
Ok(bincode::deserialize(&bytes)?)

src/requests/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ macro_rules! get_from_stream {
1717
($stream:expr, $type:ty) => {
1818
match &mut $stream {
1919
stream => {
20-
let mut read_bytes = [0u8; std::mem::size_of::<$type>()];
20+
let mut read_bytes = [0_u8; std::mem::size_of::<$type>()];
2121
stream.read_exact(&mut read_bytes)?;
2222
<$type>::from_le_bytes(read_bytes)
2323
}

0 commit comments

Comments
 (0)