fix(shadows): honor opaque(max_size) for report_only(persist) KV buffer - #133
Merged
Merged
Conversation
The generated persist_report_only arm sized its postcard buffer with `<T as MaxSize>::POSTCARD_MAX_SIZE` unconditionally, so a report_only(persist) field required its type to implement MaxSize even when it declared an explicit opaque(max_size = N). Mirror the ValueBuf sizing path, which already prefers opaque_max_size(). This lets report_only(persist) hold types that don't implement MaxSize (e.g. String-carrying enums) as long as the field declares opaque(max_size = N). Adds a compile-guard test whose field type intentionally does not implement MaxSize.
KennethKnudsen97
approved these changes
Jul 3, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
report_only(persist)fields hardcoded<T as MaxSize>::POSTCARD_MAX_SIZEfor their KV buffer, so the field type had to implementMaxSizeeven when it declared an explicitopaque(max_size = N). The parallel ValueBuf-sizing path already honored the explicit size; this makes thepersist_report_onlycodegen do the same.Effect:
report_only(persist), opaque(max_size = N)now works for types that don't implementMaxSize(e.g.String-carrying enums), which is what lets a device persist a small state-machine field in its shadow across reboots.Includes a compile-guard test (
ReportOnlyPersistOpaqueTest) whose field type intentionally lacksMaxSize.