Skip to content

Updated Folder Structure of the 'slice-codec' Crate to be More Modular - #794

Merged
InsertCreativityHere merged 3 commits into
icerpc:mainfrom
InsertCreativityHere:reorg-slice-codec-folders
Jul 30, 2026
Merged

Updated Folder Structure of the 'slice-codec' Crate to be More Modular#794
InsertCreativityHere merged 3 commits into
icerpc:mainfrom
InsertCreativityHere:reorg-slice-codec-folders

Conversation

@InsertCreativityHere

Copy link
Copy Markdown
Member

This PR makes no changes to the code, logic, or tests, it only moves code between files.

The current structure of the slice-codec is not great. There is a single folder (named buffer) which holds both the InputSource and OutputTarget traits in a single file, along with the implementations (also mixed). Everything else is dumped directly in the top-level src folder.

This PR changes the structure so these are all the top-level items:

  • decoding: Contains the actual Decoder, and the DecodeFrom implementations for all the types we support
  • encoding: Contains the actual Encoder, and the EncodeInto implementations for all the types we support
  • input_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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 buffer module into dedicated input_source and output_target modules and update call sites/imports accordingly.
  • Move encoding/decoding APIs under encoding/* and decoding/*, 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 OutputTarget is and how it relates to encoding.

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

Comment thread slice-codec/src/lib.rs
Comment thread slice-codec/src/input_source/mod.rs
Comment thread slice-codec/src/output_target/slice_output_target.rs
Comment thread slice-codec/src/input_source/slice_input_source.rs
@InsertCreativityHere
InsertCreativityHere merged commit 0973443 into icerpc:main Jul 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants