Updated Folder Structure of the 'slice-codec' Crate to be More Modular - #794
Merged
InsertCreativityHere merged 3 commits intoJul 30, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request restructures the slice-codec crate into more modular, responsibility-focused modules by separating encoding/decoding from low-level byte IO, and updating downstream imports to match the new public module layout.
Changes:
- Split the previous
buffermodule into dedicatedinput_sourceandoutput_targetmodules and update call sites/imports accordingly. - Move encoding/decoding APIs under
encoding/*anddecoding/*, and re-export them from the crate root. - Add/relocate slice- and vec-based source/target implementations into the new module structure.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| slicec/src/definition_types.rs | Updates imports to the new input_source / output_target module paths. |
| slice-codec/tests/encoding_tests.rs | Updates test imports/usages to match the new module layout. |
| slice-codec/src/lib.rs | Exposes input_source / output_target, reorganizes module structure, and re-exports encoding/decoding items. |
| slice-codec/src/input_source/mod.rs | Introduces the input_source module and InputSource trait location. |
| slice-codec/src/input_source/slice_input_source.rs | Provides the slice-based InputSource implementation under the new module structure. |
| slice-codec/src/output_target/mod.rs | Introduces the output_target module and re-exports output target implementations. |
| slice-codec/src/output_target/slice_output_target.rs | Adds the slice-based OutputTarget implementation as its own module/file. |
| slice-codec/src/output_target/vec_output_target.rs | Keeps the vec-based OutputTarget implementation under output_target and updates internal paths. |
| slice-codec/src/encoding/mod.rs | Creates the encoding module layout (encoder + encode_into + impls). |
| slice-codec/src/encoding/encode_into.rs | Adjusts imports to the new encoding/* + output_target structure. |
| slice-codec/src/encoding/encoder.rs | Adjusts imports to the new encoding/* + output_target structure. |
| slice-codec/src/encoding/encoding.rs | Adjusts imports to the new encoding/* + output_target structure for implementations. |
| slice-codec/src/decoding/mod.rs | Creates the decoding module layout (decoder + decode_from + impls). |
| slice-codec/src/decoding/decode_from.rs | Adjusts imports to the new decoding/* + input_source structure. |
| slice-codec/src/decoding/decoder.rs | Adjusts imports to the new decoding/* + input_source structure. |
| slice-codec/src/decoding/decoding.rs | Adjusts imports to the new decoding/* + input_source structure for implementations. |
| slice-codec/src/buffer/slice.rs | Removes the old combined slice input/output implementation file (content relocated). |
Comments suppressed due to low confidence (1)
slice-codec/src/output_target/mod.rs:3
- Module-level docs are currently a TODO placeholder. Since this module is part of the public API now, the docs should describe what an
OutputTargetis and how it relates to encoding.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This PR makes no changes to the code, logic, or tests, it only moves code between files.
The current structure of the
slice-codecis not great. There is a single folder (namedbuffer) which holds both theInputSourceandOutputTargettraits in a single file, along with the implementations (also mixed). Everything else is dumped directly in the top-levelsrcfolder.This PR changes the structure so these are all the top-level items:
decoding: Contains the actualDecoder, and theDecodeFromimplementations for all the types we supportencoding: Contains the actualEncoder, and theEncodeIntoimplementations for all the types we supportinput_source: low-level API for reading bytes from (possibly chunked) byte sources (knows nothing about Slice)output_target: low-level API for writing bytes to (possibly chunked) byte targets (knows nothing about Slice)error.rs: The error type definitions, which are shared by all the crate's fallible functions.lib.rs: The root of the crate, where we pull in the other modules and declare some publicly useful constants.I think this is a much cleaner structure, and better emphasizes the complete separation between the encoding/decoding halves of the code. Instead of the old design where encoding/decoding logic was mixed together in the same modules.