From 237ca6d6a29a81107710a9d89e2a729ba92e713b Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Wed, 15 May 2024 23:14:38 +0200 Subject: [PATCH] manual clippy fixes --- servicepoint2/src/bit_vec.rs | 11 +++++++++++ servicepoint2/src/compression.rs | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/servicepoint2/src/bit_vec.rs b/servicepoint2/src/bit_vec.rs index 90f0f5b..c148b89 100644 --- a/servicepoint2/src/bit_vec.rs +++ b/servicepoint2/src/bit_vec.rs @@ -76,6 +76,11 @@ impl BitVec { self.data.len() * 8 } + /// returns true if length is 0. + pub fn is_empty(&self) -> bool { + self.data.is_empty() + } + /// Get the underlying bits in their raw packed bytes form pub fn mut_data_ref(&mut self) -> &mut [u8] { self.data.as_mut_slice() @@ -174,6 +179,12 @@ pub mod c_api { (*this).len() } + /// Returns true if length is 0. + #[no_mangle] + pub unsafe extern "C" fn sp2_bit_vec_is_empty(this: *const BitVec) -> bool { + (*this).is_empty() + } + /// Gets an unsafe reference to the data of the `BitVec` instance. /// /// ## Safety diff --git a/servicepoint2/src/compression.rs b/servicepoint2/src/compression.rs index c651a1b..a8ec1a8 100644 --- a/servicepoint2/src/compression.rs +++ b/servicepoint2/src/compression.rs @@ -93,7 +93,7 @@ pub(crate) fn into_compressed( let mut encoder = Lz4EncoderBuilder::new() .build(vec![]) .expect("could not create encoder"); - encoder.write(&payload).expect("could not write payload"); + encoder.write_all(&payload).expect("could not write payload"); let (payload, _) = encoder.finish(); payload } @@ -103,7 +103,7 @@ pub(crate) fn into_compressed( ZstdEncoder::new(vec![], zstd::DEFAULT_COMPRESSION_LEVEL) .expect("could not create encoder"); encoder - .write(&payload) + .write_all(&payload) .expect("could not compress payload"); encoder.finish().expect("could not finish encoding") }