Skip to content

refactor(io): accept multiple buffer types in AncillaryBuilder#795

Open
Berrysoft wants to merge 11 commits intocompio-rs:masterfrom
Berrysoft:refactor-ancillary
Open

refactor(io): accept multiple buffer types in AncillaryBuilder#795
Berrysoft wants to merge 11 commits intocompio-rs:masterfrom
Berrysoft:refactor-ancillary

Conversation

@Berrysoft
Copy link
Copy Markdown
Member

Previously, I agreed to keep the deprecated types because there's no replacement for [MaybeUninit<u8>]. Now I refactored AncillaryBuilder to accept more buffer types, and have added a test for [MaybeUninit<u8>]. We can gracefully remove the CMsgBuilder then.

@Berrysoft Berrysoft self-assigned this Mar 26, 2026
@Berrysoft Berrysoft added package: io Related to compio-io refactor Refactoring existing code labels Mar 26, 2026
@George-Miao
Copy link
Copy Markdown
Member

How do you ensure alignment?

@Berrysoft
Copy link
Copy Markdown
Member Author

Our AncillaryData implementation treats them as unaligned.

@Berrysoft
Copy link
Copy Markdown
Member Author

I admit that there might be unsound in this PR. IoBufMut doesn't actually ensure the returned addresses are stable?

@George-Miao
Copy link
Copy Markdown
Member

I admit that there might be unsound in this PR. IoBufMut doesn't actually ensure the returned addresses are stable?

Correct

@Berrysoft
Copy link
Copy Markdown
Member Author

😢 We need to refactor the inner sys::CMsgIter then...

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

Refactors ancillary (control message) construction to allow AncillaryBuilder to operate over arbitrary IoBufMut buffers (including custom DST buffers), and removes the now-obsolete deprecated CMsg* compatibility types.

Changes:

  • Generalize AncillaryBuilder from AncillaryBuf<N> to IoBufMut and remove deprecated CMsgRef/CMsgIter/CMsgBuilder shims.
  • Remove deprecated compio-net re-exports of CMsg* types.
  • Update/add tests, including coverage for a custom DST buffer backed by [MaybeUninit<u8>].

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
compio-net/src/lib.rs Removes deprecated CMsg* type aliases now that compio_io::ancillary is the intended API.
compio-io/tests/ancillary.rs Updates tests to use AncillaryBuilder and adds a custom DST buffer test for [MaybeUninit<u8>].
compio-io/src/ancillary/windows.rs Removes CMsg* helper methods only used by the deprecated compatibility layer.
compio-io/src/ancillary/unix.rs Removes CMsg* helper methods only used by the deprecated compatibility layer.
compio-io/src/ancillary/mod.rs Generalizes AncillaryBuilder to IoBufMut and deletes deprecated CMsg* wrapper types.

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

@Berrysoft Berrysoft marked this pull request as draft March 26, 2026 17:39
@Berrysoft Berrysoft force-pushed the refactor-ancillary branch from 1ae3506 to cac3224 Compare April 4, 2026 08:54
@Berrysoft Berrysoft marked this pull request as ready for review April 4, 2026 09:27
@Berrysoft Berrysoft requested review from George-Miao and fantix April 4, 2026 09:27
@Berrysoft
Copy link
Copy Markdown
Member Author

The inner CMsgIter has been refactored to use a offset instead of a pointer.

Copy link
Copy Markdown
Contributor

@fantix fantix left a comment

Choose a reason for hiding this comment

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

LGTM!

}
}

pub(crate) struct CMsgIter {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe pub(super)? Given that this impl highly depends on the caller feeding back the same pointer, we may want to limit its scope to only the super mod.rs (and siblings perhaps in the future)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The super is declaring mod sys without pub(crate) so I think it's fine:)

@Berrysoft Berrysoft enabled auto-merge April 4, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: io Related to compio-io refactor Refactoring existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants