Skip to content

Conversation

fedemagnani
Copy link
Contributor

@fedemagnani fedemagnani commented Oct 4, 2025

Introduced the Zeroed codec type: a useful type for encoding/decoding zero-padded data of a specific length without any memory allocation.

When reading from buffer, it avoids heap-allocating a vector by "peeking" the input buffer via .chunk()[..len]: the buffer is advanced only if the given chunk has all zeros

Closes #1703

@fedemagnani fedemagnani changed the title [codec] Zeroed type (#1703) [codec] Add Zeroed type Oct 4, 2025
Comment on lines +11 to +13
pub struct Zeroed {
n: usize,
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it make more sense to have Zeroed<const N: usize> similar to the FixedSize type in utils/? Then the read_cfg Read::Cfgtype could be()`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately it looks like that in stable Rust currently, only constants that are independent of generic type resolution can be used in const generics.

Associated constants of traits (e.g. V::SIZE) are type-dependent and therefore cannot currently appear in const generic arguments. This is the tracking issue on rust to enable generic const expres

image

fedemagnani added a commit to fedemagnani/monorepo that referenced this pull request Oct 8, 2025
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.29%. Comparing base (b8610fc) to head (b61820e).
⚠️ Report is 16 commits behind head on main.

@@            Coverage Diff             @@
##             main    #1804      +/-   ##
==========================================
+ Coverage   92.18%   92.29%   +0.11%     
==========================================
  Files         302      305       +3     
  Lines       77980    79221    +1241     
==========================================
+ Hits        71885    73118    +1233     
- Misses       6095     6103       +8     
Files with missing lines Coverage Δ
codec/src/types/zeroed.rs 100.00% <100.00%> (ø)
storage/src/store/operation.rs 81.78% <100.00%> (+0.59%) ⬆️

... and 52 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8610fc...b61820e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

[codec] Add Zeroed type

2 participants