Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
jobs:
build-docs:
docker:
- image: cimg/rust:1.77
- image: cimg/rust:1.84
steps:
- checkout
- run:
Expand All @@ -26,31 +26,31 @@ 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:
name: Run tests with bytes features
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:
name: Run tests without bytes or bytes_utils
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:
name: Run tests with indexmap features
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:
Expand All @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down
9 changes: 5 additions & 4 deletions src/resp2/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use nom::{
number::streaming::be_u8,
sequence::terminated as nom_terminated,
Err as NomErr,
Parser,
};

#[cfg(feature = "bytes")]
Expand All @@ -39,13 +40,13 @@ fn to_i64(s: &[u8]) -> Result<i64, RedisParseError<&[u8]>> {

fn d_read_to_crlf(input: (&[u8], usize)) -> DResult<usize> {
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))
}

Expand Down Expand Up @@ -102,7 +103,7 @@ fn d_parse_error(input: (&[u8], usize)) -> DResult<RangeFrame> {

fn d_parse_bulkstring(input: (&[u8], usize), len: usize) -> DResult<RangeFrame> {
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())),
Expand Down Expand Up @@ -134,7 +135,7 @@ fn d_parse_array_frames(input: (&[u8], usize), len: usize) -> DResult<Vec<RangeF
len,
_input
);
nom_count(d_parse_frame, len)(input)
nom_count(d_parse_frame, len).parse(input)
}

fn d_parse_array(input: (&[u8], usize)) -> DResult<RangeFrame> {
Expand Down
4 changes: 2 additions & 2 deletions src/resp2/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<'a> Clone for BorrowedFrame<'a> {
}
}

impl<'a> Hash for BorrowedFrame<'a> {
impl Hash for BorrowedFrame<'_> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.kind().hash_prefix().hash(state);

Expand All @@ -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 {
Expand Down
43 changes: 23 additions & 20 deletions src/resp3/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -113,13 +114,13 @@ fn attach_attributes<T>(

fn d_read_to_crlf(input: (&[u8], usize)) -> DResult<usize> {
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))
}

Expand Down Expand Up @@ -213,7 +214,7 @@ fn d_parse_null(input: (&[u8], usize)) -> DResult<RangeFrame> {

fn d_parse_blobstring(input: (&[u8], usize), len: usize) -> DResult<RangeFrame> {
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()),
Expand All @@ -223,7 +224,7 @@ fn d_parse_blobstring(input: (&[u8], usize), len: usize) -> DResult<RangeFrame>

fn d_parse_bloberror(input: (&[u8], usize)) -> DResult<RangeFrame> {
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()),
Expand All @@ -233,14 +234,14 @@ fn d_parse_bloberror(input: (&[u8], usize)) -> DResult<RangeFrame> {

fn d_parse_verbatimstring(input: (&[u8], usize)) -> DResult<RangeFrame> {
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)),
Expand All @@ -266,7 +267,8 @@ fn d_parse_array_frames(input: (&[u8], usize), len: usize) -> DResult<Vec<RangeF
nom_count(
nom_map_res(d_parse_frame_or_attribute, expect_complete_index_frame::<&[u8]>),
len,
)(input)
)
.parse(input)
}

fn d_parse_kv_pairs(input: (&[u8], usize), len: usize) -> DResult<FrameMap<RangeFrame, RangeFrame>> {
Expand All @@ -276,7 +278,8 @@ fn d_parse_kv_pairs(input: (&[u8], usize), len: usize) -> DResult<FrameMap<Range
len.saturating_mul(2),
),
to_map::<&[u8]>,
)(input)
)
.parse(input)
}

fn d_parse_array(input: (&[u8], usize), len: usize) -> DResult<RangeFrame> {
Expand Down Expand Up @@ -422,7 +425,7 @@ fn d_parse_chunked_string(input: (&[u8], usize)) -> DResult<DecodedRangeFrame> {
(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),
Expand All @@ -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 => {
Expand Down
4 changes: 2 additions & 2 deletions src/resp3/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<H: Hasher>(&self, state: &mut H) {
use self::BorrowedFrame::*;
self.kind().hash_prefix().hash(state);
Expand All @@ -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 {
Expand Down