MoonProto exposes the core's safe-share configuration as a typed
SharedConfig. It contains the full portable settings set used for sharing or
editing configuration, while ClientSettingsCommand remains the compact live
state used by frequently updated terminal controls.
For field meanings, units, GUI ranges, exchange dependencies and inactive legacy fields, see the MoonDoc core settings reference. Use that reference when building an editor: the Rust scalar type alone does not describe a valid control or imply that a stored flag takes effect on every exchange.
The runtime requests the full configuration in the background immediately
after initialization. LifecycleEvent::Ready does not wait for this large
snapshot. If no valid response has arrived, the runtime retries every five
seconds without blocking market data, orders, or other initialization work.
Read the retained value from snapshot().settings().shared_config or react to
SettingsEvent::SharedConfigUpdated. build_shared_config() returns
MoonClientError::StateUnavailable until a real snapshot has been received;
the active API never substitutes a default configuration for a live core.
Start every edit from the latest retained full snapshot:
let mut config = client.settings().build_shared_config()?;
config.trading.x_sell = 6;
config.visual.chart_time_scale = 90;
client.settings().send_shared_config(&config)?;The send call queues one complete safe-share snapshot; success does not confirm
application or saving to disk. After applying it, the core broadcasts fresh full
and compact settings snapshots. Observe SettingsEvent::SharedConfigUpdated
and compare the returned fields with the requested values. The event is not a
request-specific acknowledgement and may reflect another editor's update.
There is no compare-and-save revision check. Obtain a fresh base just before sending and transfer only the user's edits into it. This reduces accidental overwrites but cannot eliminate races between editors.
If a compact settings or leverage update arrived after the latest full
snapshot, build_shared_config() overlays those newer values first. This keeps
an edit based on the newest state without allowing an older compact packet to
overwrite a newer full snapshot. This overlay does not provide concurrency control.
INI import replaces each supplied section completely, removing keys absent from
its entries. An empty entry list clears that section. Preserve keys you did not edit.
Kernel import applies sections sequentially: a later failure does not roll back
earlier changes. If the expected state does not arrive, call
refresh_shared_config() and compare the fields you changed before deciding
whether to retry.
refresh_shared_config() is available for an explicit refresh; normal
applications do not need to call it during startup because the runtime already
maintains the background request.
Use the same typed model for portable safe-share data:
let file_bytes = moonproto::shared_config::to_mbshare_bytes(&config)?;
let from_file = moonproto::shared_config::from_mbshare_bytes(&file_bytes)?;
let clipboard = moonproto::shared_config::to_mbsc_string(&config)?;
let from_clipboard = moonproto::shared_config::from_mbsc_string(&clipboard)?;The format contains portable settings only. API keys, credentials, local runtime state, temporary blacklists, and emulator state are not included. Parsing and serialization enforce the same section and compressed-payload bounds as the live protocol path.