diff --git a/.circleci/config.yml b/.circleci/config.yml index 1f078e9..8cc97bc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2 jobs: build-docs: docker: - - image: cimg/rust:1.77 + - image: cimg/rust:1.84 steps: - checkout - run: @@ -26,7 +26,7 @@ jobs: command: source tests/environ && tests/codec/runner.sh tests-bytes: docker: - - image: cimg/rust:1.77 + - image: cimg/rust:1.84 steps: - checkout - run: @@ -34,7 +34,7 @@ jobs: command: cargo test --release --features "resp2 resp3 bytes codec convert" --lib tests-no-bytes: docker: - - image: cimg/rust:1.77 + - image: cimg/rust:1.84 steps: - checkout - run: @@ -42,7 +42,7 @@ jobs: command: cargo test --release --features "resp2 resp3 convert" --lib tests-indexmap: docker: - - image: cimg/rust:1.77 + - image: cimg/rust:1.84 steps: - checkout - run: @@ -50,7 +50,7 @@ jobs: command: cargo test --release --features "index-map resp2 resp3 convert" --lib clippy-lint: docker: - - image: cimg/rust:1.77 + - image: cimg/rust:1.84 environment: CARGO_NET_GIT_FETCH_WITH_CLI: true steps: @@ -60,7 +60,7 @@ jobs: command: cargo clippy --features "bytes convert codec std resp2 resp3" --lib --tests --benches -- -Dwarnings build-no-std: docker: - - image: cimg/rust:1.77 + - image: cimg/rust:1.84 steps: - checkout - run: diff --git a/Cargo.toml b/Cargo.toml index 6f54978..3572c48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT" name = "redis-protocol" readme = "README.md" repository = "https://github.com/aembke/redis-protocol.rs" -version = "6.0.0" +version = "6.1.0" edition = "2021" exclude = ["fuzz", ".circleci", "benches"] @@ -25,13 +25,13 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] bytes = { version = "1.1", default-features = false, optional = true } bytes-utils = { version = "0.1", default-features = false, optional = true } -cookie-factory = { version = "=0.3.2", default-features = false } +cookie-factory = { version = "0.3", default-features = false } crc16 = { version = "0.4" } indexmap = { version = "2.2", optional = true } log = "0.4" -nom = { version = "7.1", default-features = false } +nom = { version = "8.0", default-features = false } libm = { version = "0.2", optional = true } -hashbrown = { version = "0.14", optional = true } +hashbrown = { version = "0.15", optional = true } tokio-util = { version = "0.7", features = ["codec"], optional = true } [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index b260880..b7f1c5c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,7 @@ #![allow(clippy::while_let_on_iterator)] #![allow(clippy::type_complexity)] #![allow(clippy::new_without_default)] +#![allow(clippy::needless_as_bytes)] #![cfg_attr(docsrs, deny(rustdoc::broken_intra_doc_links))] #![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, allow(unused_attributes))] diff --git a/src/resp2/decode.rs b/src/resp2/decode.rs index d88c777..b9adc2c 100644 --- a/src/resp2/decode.rs +++ b/src/resp2/decode.rs @@ -16,6 +16,7 @@ use nom::{ number::streaming::be_u8, sequence::terminated as nom_terminated, Err as NomErr, + Parser, }; #[cfg(feature = "bytes")] @@ -39,13 +40,13 @@ fn to_i64(s: &[u8]) -> Result> { fn d_read_to_crlf(input: (&[u8], usize)) -> DResult { decode_log_str!(input.0, _input, "Parsing to CRLF. Remaining: {:?}", _input); - let (input_bytes, data) = nom_terminated(nom_take_until(CRLF.as_bytes()), nom_take(2_usize))(input.0)?; + let (input_bytes, data) = nom_terminated(nom_take_until(CRLF.as_bytes()), nom_take(2_usize)).parse(input.0)?; Ok(((input_bytes, input.1 + data.len() + 2), data.len())) } fn d_read_to_crlf_take(input: (&[u8], usize)) -> DResult<&[u8]> { decode_log_str!(input.0, _input, "Parsing to CRLF. Remaining: {:?}", _input); - let (input_bytes, data) = nom_terminated(nom_take_until(CRLF.as_bytes()), nom_take(2_usize))(input.0)?; + let (input_bytes, data) = nom_terminated(nom_take_until(CRLF.as_bytes()), nom_take(2_usize)).parse(input.0)?; Ok(((input_bytes, input.1 + data.len() + 2), data)) } @@ -102,7 +103,7 @@ fn d_parse_error(input: (&[u8], usize)) -> DResult { fn d_parse_bulkstring(input: (&[u8], usize), len: usize) -> DResult { let offset = input.1; - let (input, data) = nom_terminated(nom_take(len), nom_take(2_usize))(input.0)?; + let (input, data) = nom_terminated(nom_take(len), nom_take(2_usize)).parse(input.0)?; Ok(( (input, offset + len + 2), RangeFrame::BulkString((offset, offset + data.len())), @@ -134,7 +135,7 @@ fn d_parse_array_frames(input: (&[u8], usize), len: usize) -> DResult DResult { diff --git a/src/resp2/types.rs b/src/resp2/types.rs index 16902d4..57fb585 100644 --- a/src/resp2/types.rs +++ b/src/resp2/types.rs @@ -132,7 +132,7 @@ impl<'a> Clone for BorrowedFrame<'a> { } } -impl<'a> Hash for BorrowedFrame<'a> { +impl Hash for BorrowedFrame<'_> { fn hash(&self, state: &mut H) { self.kind().hash_prefix().hash(state); @@ -146,7 +146,7 @@ impl<'a> Hash for BorrowedFrame<'a> { } } -impl<'a> BorrowedFrame<'a> { +impl BorrowedFrame<'_> { /// Read the `FrameKind` value for this frame. pub fn kind(&self) -> FrameKind { match self { diff --git a/src/resp3/decode.rs b/src/resp3/decode.rs index c13ec99..401c4f5 100644 --- a/src/resp3/decode.rs +++ b/src/resp3/decode.rs @@ -13,6 +13,7 @@ use nom::{ number::streaming::be_u8 as nom_be_u8, sequence::terminated as nom_terminated, Err as NomErr, + Parser, }; #[cfg(feature = "bytes")] @@ -113,13 +114,13 @@ fn attach_attributes( fn d_read_to_crlf(input: (&[u8], usize)) -> DResult { decode_log_str!(input.0, _input, "Parsing to CRLF. Remaining: {:?}", input); - let (input_bytes, data) = nom_terminated(nom_take_until(CRLF.as_bytes()), nom_take(2_usize))(input.0)?; + let (input_bytes, data) = nom_terminated(nom_take_until(CRLF.as_bytes()), nom_take(2_usize)).parse(input.0)?; Ok(((input_bytes, input.1 + data.len() + 2), data.len())) } fn d_read_to_crlf_take(input: (&[u8], usize)) -> DResult<&[u8]> { decode_log_str!(input.0, _input, "Parsing to CRLF. Remaining: {:?}", _input); - let (input_bytes, data) = nom_terminated(nom_take_until(CRLF.as_bytes()), nom_take(2_usize))(input.0)?; + let (input_bytes, data) = nom_terminated(nom_take_until(CRLF.as_bytes()), nom_take(2_usize)).parse(input.0)?; Ok(((input_bytes, input.1 + data.len() + 2), data)) } @@ -213,7 +214,7 @@ fn d_parse_null(input: (&[u8], usize)) -> DResult { fn d_parse_blobstring(input: (&[u8], usize), len: usize) -> DResult { let offset = input.1; - let (input, data) = nom_terminated(nom_take(len), nom_take(2_usize))(input.0)?; + let (input, data) = nom_terminated(nom_take(len), nom_take(2_usize)).parse(input.0)?; Ok(((input, offset + len + 2), RangeFrame::BlobString { data: (offset, offset + data.len()), @@ -223,7 +224,7 @@ fn d_parse_blobstring(input: (&[u8], usize), len: usize) -> DResult fn d_parse_bloberror(input: (&[u8], usize)) -> DResult { let ((input, offset), len) = d_read_prefix_len(input)?; - let (input, data) = nom_terminated(nom_take(len), nom_take(2_usize))(input)?; + let (input, data) = nom_terminated(nom_take(len), nom_take(2_usize)).parse(input)?; Ok(((input, offset + len + 2), RangeFrame::BlobError { data: (offset, offset + data.len()), @@ -233,14 +234,14 @@ fn d_parse_bloberror(input: (&[u8], usize)) -> DResult { fn d_parse_verbatimstring(input: (&[u8], usize)) -> DResult { let ((input, prefix_offset), len) = d_read_prefix_len(input)?; - let (input, format_bytes) = nom_terminated(nom_take(3_usize), nom_take(1_usize))(input)?; + let (input, format_bytes) = nom_terminated(nom_take(3_usize), nom_take(1_usize)).parse(input)?; if len < 4 { e!(RedisParseError::new_custom( "parse_verbatimstring", "Invalid prefix length." )); } - let (input, _) = nom_terminated(nom_take(len - 4), nom_take(2_usize))(input)?; + let (input, _) = nom_terminated(nom_take(len - 4), nom_take(2_usize)).parse(input)?; Ok(( (input, prefix_offset.saturating_add(len).saturating_add(2)), @@ -266,7 +267,8 @@ fn d_parse_array_frames(input: (&[u8], usize), len: usize) -> DResult), len, - )(input) + ) + .parse(input) } fn d_parse_kv_pairs(input: (&[u8], usize), len: usize) -> DResult> { @@ -276,7 +278,8 @@ fn d_parse_kv_pairs(input: (&[u8], usize), len: usize) -> DResult, - )(input) + ) + .parse(input) } fn d_parse_array(input: (&[u8], usize), len: usize) -> DResult { @@ -422,7 +425,7 @@ fn d_parse_chunked_string(input: (&[u8], usize)) -> DResult { (input, RangeFrame::new_end_stream()) } else { let offset = input.1; - let (input, contents) = nom_terminated(nom_take(len), nom_take(2_usize))(input.0)?; + let (input, contents) = nom_terminated(nom_take(len), nom_take(2_usize)).parse(input.0)?; ( (input, offset + contents.len() + 2), @@ -444,17 +447,17 @@ fn d_parse_non_attribute_frame(input: (&[u8], usize), kind: FrameKind) -> DResul FrameKind::BlobString => d_check_streaming(input, kind)?, FrameKind::Map => d_check_streaming(input, kind)?, FrameKind::Set => d_check_streaming(input, kind)?, - FrameKind::SimpleString => nom_map(d_parse_simplestring, map_complete_frame)(input)?, - FrameKind::SimpleError => nom_map(d_parse_simpleerror, map_complete_frame)(input)?, - FrameKind::Number => nom_map(d_parse_number, map_complete_frame)(input)?, - FrameKind::Null => nom_map(d_parse_null, map_complete_frame)(input)?, - FrameKind::Double => nom_map(d_parse_double, map_complete_frame)(input)?, - FrameKind::Boolean => nom_map(d_parse_boolean, map_complete_frame)(input)?, - FrameKind::BlobError => nom_map(d_parse_bloberror, map_complete_frame)(input)?, - FrameKind::VerbatimString => nom_map(d_parse_verbatimstring, map_complete_frame)(input)?, - FrameKind::Push => nom_map(d_parse_push, map_complete_frame)(input)?, - FrameKind::BigNumber => nom_map(d_parse_bignumber, map_complete_frame)(input)?, - FrameKind::Hello => nom_map(d_parse_hello, map_complete_frame)(input)?, + FrameKind::SimpleString => nom_map(d_parse_simplestring, map_complete_frame).parse(input)?, + FrameKind::SimpleError => nom_map(d_parse_simpleerror, map_complete_frame).parse(input)?, + FrameKind::Number => nom_map(d_parse_number, map_complete_frame).parse(input)?, + FrameKind::Null => nom_map(d_parse_null, map_complete_frame).parse(input)?, + FrameKind::Double => nom_map(d_parse_double, map_complete_frame).parse(input)?, + FrameKind::Boolean => nom_map(d_parse_boolean, map_complete_frame).parse(input)?, + FrameKind::BlobError => nom_map(d_parse_bloberror, map_complete_frame).parse(input)?, + FrameKind::VerbatimString => nom_map(d_parse_verbatimstring, map_complete_frame).parse(input)?, + FrameKind::Push => nom_map(d_parse_push, map_complete_frame).parse(input)?, + FrameKind::BigNumber => nom_map(d_parse_bignumber, map_complete_frame).parse(input)?, + FrameKind::Hello => nom_map(d_parse_hello, map_complete_frame).parse(input)?, FrameKind::ChunkedString => d_parse_chunked_string(input)?, FrameKind::EndStream => d_return_end_stream(input)?, FrameKind::Attribute => { diff --git a/src/resp3/types.rs b/src/resp3/types.rs index 6277a02..b0517d3 100644 --- a/src/resp3/types.rs +++ b/src/resp3/types.rs @@ -498,7 +498,7 @@ impl<'a> Clone for BorrowedFrame<'a> { impl Eq for BorrowedFrame<'_> {} -impl<'a> Hash for BorrowedFrame<'a> { +impl Hash for BorrowedFrame<'_> { fn hash(&self, state: &mut H) { use self::BorrowedFrame::*; self.kind().hash_prefix().hash(state); @@ -523,7 +523,7 @@ impl<'a> Hash for BorrowedFrame<'a> { } } -impl<'a> BorrowedFrame<'a> { +impl BorrowedFrame<'_> { /// Read the `FrameKind` value for this frame. pub fn kind(&self) -> FrameKind { match self {