-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
SavedStruct: Introduce saved_struct_get_metadata #3392
SavedStruct: Introduce saved_struct_get_metadata #3392
Conversation
dc245a5
to
5f78fc0
Compare
Rebased on 0.98.2 and its API level - should be good to go. |
Note: The merge incrementing the minor API version is probably wrong due to the removal of |
That is true. To be honest I'm still thinking what to do with this PR. |
The const-correctness change should be unambiguously an improvement, since as far as I can tell it's currently an outlier, and all the other write-esque functions in Furi are const-qualified like this. I see the metadata function as an improvement over the existing function, because it preserves all the functionality that is currently possible, while also accommodating for additional backwards compatibility-related use cases*. Getters with optional output arguments are also quite common AFAIK (e.g. this approach is used by * Aside from the custom apps (saved struct seems ideal for storing progression/saves in apps), I can foresee this being relevant for example for the Dolphin State - once dolphin's serialized state needs to (IMO inevitably) be expanded, you might not necessarily want to reset everyone's progress, especially if potential future additions end up just adding some extra fields at the end of the state structure. |
Do you mind if we move this PR to next release? |
That's fine! It's not a high priority change at all. |
73812ac
to
c2f49db
Compare
Updated for 0.99.1. |
…get_metadata This new function can obtain the magic value, version and payload size all at once. This makes the function useful e.g. for backwards compatibility.
c2f49db
to
17f66c6
Compare
What's new
This PR makes two changes to the SavedStruct toolbox lib:
saved_struct_get_payload_size
withsaved_struct_get_metadata
. While the original function compared the magic and version, and only returned the size of the saved data, my replacement obtains the magic and version alongside size.saved_struct_get_payload_size
is entirely superseded, so I felt like it's appropriate to replace it instead of adding a new API call.saved_struct_save
gets itsdata
parameter const-qualified. This change needs no further explanation, and since I bumped up the API version with the other change anyway, I went for it. I also const-qualified all the functions in other modules that exclusively calledsaved_struct_save
.This change allows applications to easier handle backwards compatibility if they desire so. Now, users can obtain the version number from
saved_struct_get_metadata
and fall back to legacy file handling with a pattern like:Verification
The following sample app verifies the functionality:
Checklist (For Reviewer)