Skip to content

Conversation

@George-Miao
Copy link
Member

@George-Miao George-Miao commented Jan 24, 2026

Closes #577.

@code-withAshish

The new API gives implentator a &Slice<B> as the sliced view into the buffer. With Bytes, it's possible to do this:

let (begin, end) = (slice.begin(), slice.end());
let bytes = if let Some(end) = end {
    slice.as_inner().slice(begin..end)
} else {
    slice.as_inner().slice(begin..)
};
// ... decode with new Bytes

I have added a helper function for Slice<Bytes>, slice_bytes to do exactly this. Generally, one can still use &Slice<B: IoBuf> as a &[u8] since it implements Deref<Target = [u8]>.

@George-Miao George-Miao self-assigned this Jan 24, 2026
@George-Miao George-Miao added enhancement New feature or request package: io Related to compio-io breaking change labels Jan 24, 2026
@George-Miao George-Miao requested a review from Copilot January 24, 2026 17:09
@George-Miao George-Miao added the package: buf Related to compio-buf label Jan 24, 2026
@George-Miao George-Miao force-pushed the feat/io/framed-generic-buf branch from 09fb8dd to 7daa31e Compare January 24, 2026 17:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.

Comments suppressed due to low confidence (1)

compio-io/src/framed/read.rs:105

  • Buffer::reserve currently treats ReserveError::NotSupported as a no-op. If a non-growable buffer is full, io.append(buf) will read into a 0-length Uninit slice and likely return Ok(0), which gets treated as EOF. Consider using try_reserve here and, on NotSupported (or if the buffer is already filled), return an explicit error (e.g. io::ErrorKind::OutOfMemory / frame-too-large) instead of attempting a read.
                    buf.reserve(16);

                    let fut = Box::pin(async move {
                        let res = buf.with(|buf| io.append(buf)).await;
                        (io, BufResult(res, buf))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@George-Miao George-Miao force-pushed the feat/io/framed-generic-buf branch from b8e9d1d to 416199d Compare January 25, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change enhancement New feature or request package: buf Related to compio-buf package: io Related to compio-io

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow codec::Encoder and codec::Decoder to take any IoBuf[Mut]

1 participant