Skip to content

Commit 9168cb4

Browse files
committed
Updat to Rust edition 2024
And fix all clippy warnings.
1 parent a5e44bc commit 9168cb4

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords = [ "protocol", "fastcgi", "web", "tokio", "async" ]
66
categories = [ "web-programming", "network-programming", "asynchronous" ]
77
version = "1.2.0"
88
authors = ["Daniel Goß <developer@flashsystems.de>"]
9-
edition = "2021"
9+
edition = "2024"
1010
homepage = "https://github.com/FlashSystems/tokio-fastcgi"
1111
repository = "https://github.com/FlashSystems/tokio-fastcgi"
1212
readme = "README.md"

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ impl <W: AsyncWrite + Unpin> Request<W> {
542542
let length_byte2 = u32::from(src.read_u8()?);
543543
let length_byte10 = u32::from(src.read_u16::<BigEndian>()?);
544544

545-
Ok((length & 0x7f) << 24 | length_byte2 << 16 | length_byte10)
545+
Ok(((length & 0x7f) << 24) | (length_byte2 << 16) | length_byte10)
546546
}
547547
}
548548

@@ -977,7 +977,7 @@ pub struct Requests <R: AsyncRead + Unpin + Send, W: AsyncWrite + Unpin + Send>
977977
max_reqs: u8
978978
}
979979

980-
impl <'w, R: AsyncRead + Unpin + Send, W: AsyncWrite + Unpin + Send> Requests<R, W> {
980+
impl <R: AsyncRead + Unpin + Send, W: AsyncWrite + Unpin + Send> Requests<R, W> {
981981
/// Creates a new [`Requests`] instance.
982982
///
983983
/// As soon as a new connection is accepted the read and write parts of this
@@ -1302,11 +1302,11 @@ impl <W: AsyncWrite + Unpin> OutStream<W> {
13021302

13031303
// Check if the data can be transmitted in one chunk.
13041304
// If not, split the data in chunks of u16 - 1 size.
1305-
if data.len() < u16::max_value() as usize {
1305+
if data.len() < u16::MAX as usize {
13061306
Ok(self.orw.write_data(self.record_type, data).await?)
13071307
} else {
13081308
// Transmit large streams in junks of 64k
1309-
const JUNK_SIZE: usize = (u16::max_value() - 1) as usize;
1309+
const JUNK_SIZE: usize = (u16::MAX - 1) as usize;
13101310
for offset in (0..data.len()).step_by(JUNK_SIZE) {
13111311
self.orw.write_data(self.record_type, &data[offset..(offset + JUNK_SIZE).min(data.len())]).await?;
13121312
}

tests/commons.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ pub enum RecordFlags {
4545
pub fn create_record(request_type: RecordType, request_id: u8, padding: u8, data: &[u8]) -> Vec<u8> {
4646
let content_length = data.len() as u16;
4747

48-
let mut record = vec![0x01, request_type as u8, 0x00, request_id, (content_length >> 8 & 0xFF) as u8, (content_length & 0xFF) as u8, padding, 0x00];
48+
let mut record = vec![0x01, request_type as u8, 0x00, request_id, ((content_length >> 8) & 0xFF) as u8, (content_length & 0xFF) as u8, padding, 0x00];
4949

5050
record.extend_from_slice(data);
51-
record.extend_from_slice(&*vec![0u8; padding as usize]);
51+
record.extend_from_slice(&vec![0u8; padding as usize]);
5252

5353
record
5454
}
@@ -86,14 +86,14 @@ impl TestCase for TestParamsInOut {
8686
// Check the parameters
8787
let sp = request.get_param("SERVER_PORT");
8888
assert!(sp.is_some());
89-
assert_eq!(sp.unwrap(), &[b'8', b'0']);
89+
assert_eq!(sp.unwrap(), b"80");
9090
let sp = request.get_str_param("SERVER_PORT");
9191
assert!(sp.is_some());
9292
assert_eq!(sp.unwrap(), "80");
9393

9494
let tst = request.get_param("TEST");
9595
assert!(tst.is_some());
96-
assert_eq!(tst.unwrap(), &[b'Y', b'E', b'S']);
96+
assert_eq!(tst.unwrap(), b"YES");
9797
let tst = request.get_str_param("TEST");
9898
assert!(tst.is_some());
9999
assert_eq!(tst.unwrap(), "YES");
@@ -112,9 +112,9 @@ impl TestCase for TestParamsInOut {
112112
assert_eq!(params[0].0, "noutf8");
113113
assert_eq!(params[0].1, &[b'N', b'O', 0xF0]);
114114
assert_eq!(params[1].0, "server_port");
115-
assert_eq!(params[1].1, &[b'8', b'0']);
115+
assert_eq!(params[1].1, b"80");
116116
assert_eq!(params[2].0, "test");
117-
assert_eq!(params[2].1, &[b'Y', b'E', b'S']);
117+
assert_eq!(params[2].1, b"YES");
118118

119119
// Test the string params iterator
120120
let mut params: Vec<(&str, Option<&str>)> = request.str_params_iter().unwrap().collect();

0 commit comments

Comments
 (0)