![]() |
BSB Developer Docs
|
Settings storage bridge for JavaScript applications. More...
Go to the source code of this file.
Typedefs | |
| typedef struct JsAppSettingsStorage | JsAppSettingsStorage |
Enumerations | |
| enum | JsAppSettingsStorageStatus { JsAppSettingsStorageStatusOk , JsAppSettingsStorageStatusSchemaMissing , JsAppSettingsStorageStatusSchemaInvalid , JsAppSettingsStorageStatusStorageFailure , JsAppSettingsStorageStatusesCount } |
| Result of building a settings storage. More... | |
Functions | |
| JsAppSettingsStorage * | js_app_settings_storage_alloc (const char *app_id, JsAppSettingsStorageStatus *status) |
| Build a settings storage for an application. | |
| void | js_app_settings_storage_free (JsAppSettingsStorage *instance) |
| Release a settings storage. | |
| bool | js_app_settings_storage_load (JsAppSettingsStorage *instance) |
| Load values from the application's data file. | |
| bool | js_app_settings_storage_save (JsAppSettingsStorage *instance) |
| Write every value to the application's data file. | |
| bool | js_app_settings_storage_reset (JsAppSettingsStorage *instance) |
| Reset every value to its default. | |
| bool | js_app_settings_storage_export (const JsAppSettingsStorage *instance, FuriString *data) |
| Export the settings document. | |
| bool | js_app_settings_storage_import (JsAppSettingsStorage *instance, const char *data, size_t size) |
| Import a settings document. | |
| const SettingProviderSetting * | js_app_settings_storage_get_root (JsAppSettingsStorage *instance) |
| Get the root setting of the descriptor tree. | |
| const JsAppSettingsNode * | js_app_settings_storage_get_node (const SettingProviderSetting *instance) |
| Get the schema node a setting was built from. | |
| void * | js_app_settings_storage_get_value (const SettingProviderSetting *instance) |
| Get the value behind a setting. | |
Settings storage bridge for JavaScript applications.
Composes a parsed settings schema into a setting provider descriptor tree with a single POD value block, backed by an application data file.
Result of building a settings storage.
Set by js_app_settings_storage_alloc(); every failure status pairs with a NULL return.
| JsAppSettingsStorage * js_app_settings_storage_alloc | ( | const char * | app_id, |
| JsAppSettingsStorageStatus * | status ) |
Build a settings storage for an application.
Parses the application's settings schema, composes the provider descriptor tree and allocates the value block. Does not load any values; call js_app_settings_storage_load() before reading any.
| [in] | app_id | Application identifier. |
| [out] | status | Resulting status. |
| bool js_app_settings_storage_export | ( | const JsAppSettingsStorage * | instance, |
| FuriString * | data ) |
Export the settings document.
Serializes the current values into a complete settings document. Values must be current: call js_app_settings_storage_load() before exporting.
| [in] | instance | Storage. |
| [out] | data | Serialized document data. |
| void js_app_settings_storage_free | ( | JsAppSettingsStorage * | instance | ) |
Release a settings storage.
Releases the storage with the schema tree, the descriptor tree and the value block.
| [in] | instance | Storage returned by js_app_settings_storage_alloc(). |
| const JsAppSettingsNode * js_app_settings_storage_get_node | ( | const SettingProviderSetting * | instance | ) |
Get the schema node a setting was built from.
| [in] | instance | Setting from the descriptor tree, not the root. |
| const SettingProviderSetting * js_app_settings_storage_get_root | ( | JsAppSettingsStorage * | instance | ) |
Get the root setting of the descriptor tree.
| [in] | instance | Storage. |
| void * js_app_settings_storage_get_value | ( | const SettingProviderSetting * | instance | ) |
Get the value behind a setting.
| [in] | instance | Setting from the descriptor tree, not the root. |
| bool js_app_settings_storage_import | ( | JsAppSettingsStorage * | instance, |
| const char * | data, | ||
| size_t | size ) |
Import a settings document.
Strict counterpart of js_app_settings_storage_export(): the document must carry the settings version and every field with a valid value; unknown keys are dropped.
| [in] | instance | Storage. |
| [in] | data | Document data to import. |
| [in] | size | Length of the document data. |
| bool js_app_settings_storage_load | ( | JsAppSettingsStorage * | instance | ) |
Load values from the application's data file.
Missing and invalid fields fall back to the schema defaults; an absent or unparsable file still loads every default.
| [in] | instance | Storage. |
| bool js_app_settings_storage_reset | ( | JsAppSettingsStorage * | instance | ) |
Reset every value to its default.
Substitutes the schema default for every field and writes the document.
| [in] | instance | Storage. |
| bool js_app_settings_storage_save | ( | JsAppSettingsStorage * | instance | ) |
Write every value to the application's data file.
The file is rebuilt as a whole; a single invalid field discards the save.
| [in] | instance | Storage. |