Skip to content

fix(shadows): honor opaque(max_size) for report_only(persist) KV buffer - #133

Merged
MathiasKoch merged 1 commit into
masterfrom
fix/report-only-persist-opaque-max-size
Jul 3, 2026
Merged

MathiasKoch merged 1 commit into
masterfrom
fix/report-only-persist-opaque-max-size

Conversation

@MathiasKoch

Copy link
Copy Markdown
Member

Summary

report_only(persist) fields hardcoded <T as MaxSize>::POSTCARD_MAX_SIZE for their KV buffer, so the field type had to implement MaxSize even when it declared an explicit opaque(max_size = N). The parallel ValueBuf-sizing path already honored the explicit size; this makes the persist_report_only codegen do the same.

Effect: report_only(persist), opaque(max_size = N) now works for types that don't implement MaxSize (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 lacks MaxSize.

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.
@MathiasKoch
MathiasKoch merged commit 3d68853 into master Jul 3, 2026
5 checks passed
@MathiasKoch
MathiasKoch deleted the fix/report-only-persist-opaque-max-size branch July 3, 2026 11:18
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.

2 participants