Skip to content

feat(buf): add ensure_init for convenience#884

Merged
George-Miao merged 5 commits intocompio-rs:masterfrom
Berrysoft:dev/ensure-init
Apr 21, 2026
Merged

feat(buf): add ensure_init for convenience#884
George-Miao merged 5 commits intocompio-rs:masterfrom
Berrysoft:dev/ensure-init

Conversation

@Berrysoft
Copy link
Copy Markdown
Member

Inspired by BorrowedCursor::ensure_init.

@Berrysoft Berrysoft added enhancement New feature or request package: buf Related to compio-buf labels Apr 21, 2026
@Berrysoft Berrysoft self-assigned this Apr 21, 2026
Copy link
Copy Markdown
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

Adds a convenience IoBufMut::ensure_init() helper (inspired by BorrowedCursor::ensure_init) and refactors several call sites to use it, removing repeated MaybeUninit-to-[u8] initialization patterns.

Changes:

  • Add IoBufMut::ensure_init() default method to zero-initialize and return a &mut [u8].
  • Update TLS read path and Windows stdio fallback reads to use ensure_init() instead of manual MaybeUninit handling.
  • Simplify QUIC read_to_end buffer initialization/copying logic (removing an unsafe slice conversion).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
compio-buf/src/io_buf.rs Introduces IoBufMut::ensure_init() default method.
compio-tls/src/stream.rs Replaces manual init + unsafe cast with ensure_init() in read_futures.
compio-quic/src/recv_stream.rs Uses slice(..len) + ensure_init(); simplifies chunk copy.
compio-io/src/ancillary/mod.rs Uses ensure_init() before constructing ancillary message iterator.
compio-fs/src/stdio/windows.rs Uses ensure_init() in the non-read_buf Windows stdio read path.

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

Comment thread compio-quic/src/recv_stream.rs Outdated
Comment thread compio-buf/src/io_buf.rs Outdated
Berrysoft and others added 2 commits April 21, 2026 23:25
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@George-Miao George-Miao left a comment

Choose a reason for hiding this comment

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

LGTM

@George-Miao George-Miao merged commit 615af96 into compio-rs:master Apr 21, 2026
71 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants