This repository was archived by the owner on Aug 15, 2025. It is now read-only.
Merged
Conversation
Contributor
Author
|
@haata the only thing that is left of #427 is that #[repr(transparent)]
struct BincodeVec<T, const N: usize>(heapless::Vec<T, N>);
impl<T: Decode + Default, const N: usize> Decode for BincodeVec<T, N> {
fn decode<D: bincode::de::Decoder>(
mut decoder: D,
) -> Result<Self, bincode::error::DecodeError> {
let len = usize::decode(&mut decoder)?;
let mut vec = heapless::Vec::default();
for _ in 0..len {
// TODO: handle the heapless error?
let _ = vec.push(T::decode(&mut decoder)?);
}
Ok(Self(vec))
}
}
impl<T: Encode, const N: usize> Encode for BincodeVec<T, N> {
fn encode<E: bincode::enc::Encoder>(
&self,
mut encoder: E,
) -> Result<(), bincode::error::EncodeError> {
self.0.len().encode(&mut encoder)?;
for val in self.0.iter() {
val.encode(&mut encoder)?;
}
Ok(())
}
} |
ghost
reviewed
Oct 26, 2021
Codecov Report
@@ Coverage Diff @@
## trunk #428 +/- ##
==========================================
- Coverage 71.04% 69.28% -1.76%
==========================================
Files 41 41
Lines 2811 2924 +113
==========================================
+ Hits 1997 2026 +29
- Misses 814 898 +84
Continue to review full report at Codecov.
|
ghost
approved these changes
Nov 7, 2021
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
#427 uncovered some issues.
'#'in a row with no attribute group.bincode_derivenow handles this correctlybincode_derivenow supports min_const_genericsbincode_derivenow supports c-style enums where the variants have a fixed valueFor 3 I have made it so that bincode_derive outputs code like this:
CStyleEnum output