meta
meta subcommands. JSON metadata helpers for reading and writing dot-delimited key paths.These helpers operate on serde_json::Value trees and are shared by all
meta subcommands across artifacts, iterations, and tasks. They support:
- resolving values at a dot path (
outer.inner.leaf) - inserting values at a dot path, auto-creating intermediate objects
- removing values at a dot path
- parsing scalar strings into typed JSON values
- flattening nested objects into dot-path key/value pairs
- formatting values for human display
const MAX_DEPTH
const MAX_DEPTH: usize = 32;Maximum number of dot-delimited segments allowed in a key path.
fn flatten_dot_paths
pub fn flatten_dot_paths(root: &Value) -> Vec<(String, String)>Flatten a JSON value into dot-path key/value pairs for --raw output.
Nested objects are recursively flattened so each leaf becomes a single
key.subkey=value entry. Non-object roots produce a single empty-key entry.
| Parameter | Type | Description |
|---|---|---|
root |
&Value | the metadata value to flatten |
| returns | Vec<(String, String)> | One (dot path, formatted value) pair per leaf, in the map’s key order; an empty object adds no pair. |
fn format_meta_value
pub fn format_meta_value(value: &Value) -> StringFormat a JSON value as a human-friendly string.
Strings are emitted unquoted; all other types are pretty-printed as JSON.
| Parameter | Type | Description |
|---|---|---|
value |
&Value | the value to format |
| returns | String | The string itself for a JSON string, else the pretty-printed JSON text. |
fn parse_scalar
pub fn parse_scalar(s: &str) -> ValueParse a string into the most specific JSON scalar type.
Recognizes true/false, integers, and floats. All other inputs become
JSON strings.
| Parameter | Type | Description |
|---|---|---|
s |
&str | the raw value, as given on the command line |
| returns | Value | A JSON boolean for exactly true or false, a number for an i64 or a finite f64, else a JSON string. |
fn resolve_path
pub fn resolve_path<'a>(root: &'a Value, path: &str) -> Option<&'a Value>Walk a dot-delimited path through nested objects, returning the leaf value.
| Parameter | Type | Description |
|---|---|---|
root |
&'a Value | the metadata value to search |
path |
&str | the dot-delimited key path, such as outer.inner.leaf |
| returns | Option<&'a Value> | The value at path, or None when a key is missing or a segment meets a non-object. |
fn set_path
pub fn set_path(root: &mut Value, path: &str, value: Value) -> boolInsert a value at a dot-delimited path, creating intermediate objects as needed.
| Parameter | Type | Description |
|---|---|---|
root |
&mut Value | the metadata object to change |
path |
&str | the dot-delimited key path; a non-object on the way is replaced by an object |
value |
Value | the value to store at the leaf |
| returns | bool | Returns false and leaves root unchanged if path exceeds MAX_DEPTH segments or if root is not an object. Otherwise it stores the value and returns true. |
fn unset_path
pub fn unset_path(root: &mut Value, path: &str) -> boolRemove a value at a dot-delimited path.
| Parameter | Type | Description |
|---|---|---|
root |
&mut Value | the metadata object to change |
path |
&str | the dot-delimited key path of the value to remove |
| returns | bool | Returns true if a value was removed, false otherwise. |
fn flatten_object
fn flatten_object(map: &Map<String, Value>, prefix: &str, out: &mut Vec<(String, String)>)Append one dot-path entry per leaf of map, recursing into nested objects.
| Parameter | Type | Description |
|---|---|---|
map |
&Map<String, Value> | the object to flatten |
prefix |
&str | the dot path of map itself; empty at the root |
out |
&mut Vec<(String, String)> | the list that receives each (dot path, formatted value) pair |
fn set_nested
fn set_nested(map: &mut Map<String, Value>, segments: &[&str], value: Value)Store value under the key path segments, replacing any non-object on the way with an empty object.
| Parameter | Type | Description |
|---|---|---|
map |
&mut Map<String, Value> | the object at the current depth |
segments |
&[&str] | the remaining keys of the path; nothing happens when it is empty |
value |
Value | the value to store at the last key |
fn unset_nested
fn unset_nested(map: &mut Map<String, Value>, segments: &[&str]) -> boolRemove the value under the key path segments.
| Parameter | Type | Description |
|---|---|---|
map |
&mut Map<String, Value> | the object at the current depth |
segments |
&[&str] | the remaining keys of the path |
| returns | bool | true when the last key existed and was removed; false when segments is empty, a key is missing or a segment meets a non-object. |