-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Decode breaks when not calling write!
#457
Comments
This should not be too hard to fix, by remembering whether a |
This would increase code size somewhat. Also, making Formatter zero-sized leads to big code size wins (#456), and this would prevent that. Assuming we can break wire format, I think this can be fixed with a new trait without breaking API (also fixing #455 #458).
// This trait would be "public but not really", in defmt::export.
// Not intended to be impl'd by the end user, only by code in `defmt`, and the macros.
// This allows us to change it in the future again if needed.
trait RawFormat {
fn format_tag() -> u16,
fn format_data(&self);
}
// The current Format trait stays unchanged
trait Format {
fn format(&self, fmt: Formatter<'_>);
}
impl<T: Format + ?Sized> RawFormat for T {
fn format_tag() -> u16 {
internp!("{=_format}") // some new special tag
}
fn format_data(&self) {
self.format(Formatter::new());
defmt::export::write_u8(0x00); // some terminator byte
}
}
impl<T: RawFormat> RawFormat for [T] {
fn format_tag() -> u16 {
internp!("{=_slice}") // some new special tag
}
fn format_data(&self) {
defmt::export::write_tag(T::format_tag());
defmt::export::write_usize(self.len());
for x in self {
x.format_data();
}
}
}
impl<T: RawFormat, const N: usize> RawFormat for [T;N] { .. etc } |
That sounds good, I guess we should really focus on allowing breaking changes to the wire format then |
Actually that is technically breaking: primitives like |
Maybe User code might want to do |
this appears to already have been fixed in the |
produces
I guess this is somewhat related to #455
The text was updated successfully, but these errors were encountered: