Skip to content
Merged
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "linkedbytes"
version = "0.1.12"
version = "0.1.13"
authors = ["Volo Team <volo@cloudwego.io>"]
edition = "2021"
description = "LinkedBytes is a linked list of Bytes and BytesMut."
Expand All @@ -17,5 +17,5 @@ maintenance = { status = "actively-developed" }

[dependencies]
bytes = "1"
tokio = { version = "1", features = ["io-util"] }
faststr = "0.2"
tokio = { version = "1", features = ["io-util"] }
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ impl LinkedBytes {
}

#[inline]
pub fn bytes(&self) -> &BytesMut {
pub const fn bytes(&self) -> &BytesMut {
&self.bytes
}

#[inline]
pub fn bytes_mut(&mut self) -> &mut BytesMut {
pub const fn bytes_mut(&mut self) -> &mut BytesMut {
&mut self.bytes
}

Expand Down Expand Up @@ -103,7 +103,7 @@ impl LinkedBytes {
self.list.push_back(node);
}

pub fn io_slice(&mut self) -> Vec<IoSlice<'_>> {
pub fn io_slice(&self) -> Vec<IoSlice<'_>> {
let mut ioslice = Vec::with_capacity(self.list.len() + 1);
for node in self.list.iter() {
let bytes = node.as_ref();
Expand Down Expand Up @@ -233,7 +233,7 @@ impl LinkedBytes {
}

// adjust the outer [IoSlice]
base_ptr = unsafe { (base_ptr as *mut IoSlice).add(remove) };
base_ptr = unsafe { base_ptr.add(remove) };
len -= remove;
if len == 0 {
assert!(
Expand All @@ -242,7 +242,7 @@ impl LinkedBytes {
);
} else {
// adjust the inner IoSlice
let inner_slice = unsafe { &mut *(base_ptr as *mut IoSlice) };
let inner_slice = unsafe { &mut *base_ptr };
let (inner_ptr, inner_len) = (inner_slice.as_ptr(), inner_slice.len());
let remaining = n - accumulated_len;
assert!(
Expand Down
Loading