Enable PacketBuilder in no_std (alloc/slice) while preserving std API#135
Open
xyzzyz wants to merge 1 commit intoJulianSchmid:masterfrom
Open
Enable PacketBuilder in no_std (alloc/slice) while preserving std API#135xyzzyz wants to merge 1 commit intoJulianSchmid:masterfrom
xyzzyz wants to merge 1 commit intoJulianSchmid:masterfrom
Conversation
PacketBuilder serialization is split from std::io::Write so packet building works in no_std environments while keeping std behavior intact. Key changes - Introduce an internal writer abstraction (`CoreWrite`) and internal `WriteError<IO, Content>` in `src/writer.rs`. - Add an explicit `alloc` feature and make `std` depend on `alloc`. - Make `PacketBuilder` available without `std`. - Keep std `write(...) -> BuildWriteError` API, with `BuildWriteError` remaining std-only. - Add no_std-capable write APIs: - `write_to_vec` (alloc) with `BuildVecWriteError` - `write_to_slice` (no alloc) with `BuildSliceWriteError` - Refactor IPv4/IPv6 extension writing through shared internal methods used by both std and no_std paths. - Add docsrs cfg annotations for alloc-only APIs. - Add focused tests for vec and slice write paths: - write to empty vec - write to pre-populated vec - write to slice success path - write to slice too-small error path Compatibility - std users keep existing `PacketBuilder::write` behavior. - no_std users gain packet serialization through vec/slice writers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PacketBuilder serialization is split from std::io::Write so packet building works in no_std environments while keeping std behavior intact.
Key changes
CoreWrite) and internalWriteError<IO, Content>insrc/writer.rs.allocfeature and makestddepend onalloc.PacketBuilderavailable withoutstd.write(...) -> BuildWriteErrorAPI, withBuildWriteErrorremaining std-only.write_to_vec(alloc) withBuildVecWriteErrorwrite_to_slice(no alloc) withBuildSliceWriteErrorCompatibility
PacketBuilder::writebehavior.