From 81208b9043ae7f99dfcc866f7f5782adc6d85fdb Mon Sep 17 00:00:00 2001 From: TimLuq Date: Tue, 29 Oct 2024 14:33:16 +0100 Subject: [PATCH] v0.1.10: fix for bytequeue and `http_1` --- Cargo.toml | 2 +- src/byte_chunk.rs | 8 ++++++++ src/http_body_1.rs | 2 +- src/lib.rs | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 830c7b4..e7dff1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bytedata" -version = "0.1.9" +version = "0.1.10" edition = "2021" rust-version = "1.75" description = "Representation of a byte slice that is either static, borrowed, or shared." diff --git a/src/byte_chunk.rs b/src/byte_chunk.rs index e639909..6a39fc3 100644 --- a/src/byte_chunk.rs +++ b/src/byte_chunk.rs @@ -14,6 +14,10 @@ impl ByteChunk { pub const LEN: usize = 14; /// Create a `ByteChunk` from a slice. + /// + /// # Panics + /// + /// Panics if the slice is larger than [`ByteChunk::LEN`]. #[inline] #[must_use] pub const fn from_slice(data: &[u8]) -> Self { @@ -34,6 +38,10 @@ impl ByteChunk { } /// Create a `ByteChunk` from a fixed-size array. + /// + /// # Panics + /// + /// Panics if the array is larger than [`ByteChunk::LEN`]. #[inline] #[must_use] pub const fn from_array(data: &[u8; L]) -> Self { diff --git a/src/http_body_1.rs b/src/http_body_1.rs index 54b86e6..a64ff92 100644 --- a/src/http_body_1.rs +++ b/src/http_body_1.rs @@ -94,7 +94,7 @@ impl<'a> http_body::Body for crate::ByteQueue<'a> { let Some(mut aa) = this.pop_front() else { return Poll::Ready(None); }; - if this.len() > 0xFFFF { + if aa.len() > 0xFFFF { this.push_front(aa.sliced(0xFFFF..)); aa.make_sliced(0..0xFFFF); } diff --git a/src/lib.rs b/src/lib.rs index 5b70d91..d4c06c7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -303,6 +303,10 @@ impl<'a> StrSliceResult<'a> { } /// Returns the sliced `str` if the slice was valid. Otherwise panics. + /// + /// # Panics + /// + /// Will panic if the slice was [`StrSliceResult::OutOfBounds`] or would result in [`StrSliceResult::InvalidUtf8`]. #[must_use] #[inline] pub const fn unwrap(self) -> &'a str {