MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / parse_driver_config_json

Function parse_driver_config_json

crates/openshell-cli/src/run.rs:1640–1657  ·  view source on GitHub ↗
(value: &str)

Source from the content-addressed store, hash-verified

1638}
1639
1640fn parse_driver_config_json(value: &str) -> Result<prost_types::Struct> {
1641 let parsed: serde_json::Value = serde_json::from_str(value)
1642 .into_diagnostic()
1643 .wrap_err("--driver-config-json must be valid JSON")?;
1644
1645 let serde_json::Value::Object(fields) = parsed else {
1646 return Err(miette!(
1647 "--driver-config-json must be a JSON object keyed by driver name"
1648 ));
1649 };
1650
1651 Ok(prost_types::Struct {
1652 fields: fields
1653 .into_iter()
1654 .map(|(key, value)| json_to_protobuf_value(value).map(|value| (key, value)))
1655 .collect::<Result<_>>()?,
1656 })
1657}
1658
1659fn json_to_protobuf_value(value: serde_json::Value) -> Result<prost_types::Value> {
1660 use prost_types::{ListValue, Struct, Value, value::Kind};

Calls 1

json_to_protobuf_valueFunction · 0.85