-
-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for 427 #428
Fixes for 427 #428
Conversation
@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(())
}
} |
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.
|
#427 uncovered some issues.
'#'
in a row with no attribute group.bincode_derive
now handles this correctlybincode_derive
now supports min_const_genericsbincode_derive
now 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