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

Function get_quantity

crates/openshell-server/src/compute/mod.rs:1632–1644  ·  view source on GitHub ↗
(s: &prost_types::Struct, section: &str, key: &str)

Source from the content-addressed store, hash-verified

1630 resources: &Option<prost_types::Struct>,
1631) -> Option<DriverResourceRequirements> {
1632 fn get_quantity(s: &prost_types::Struct, section: &str, key: &str) -> String {
1633 s.fields
1634 .get(section)
1635 .and_then(|v| match v.kind.as_ref() {
1636 Some(prost_types::value::Kind::StructValue(inner)) => inner.fields.get(key),
1637 _ => None,
1638 })
1639 .and_then(|v| match v.kind.as_ref() {
1640 Some(prost_types::value::Kind::StringValue(val)) => Some(val.clone()),
1641 _ => None,
1642 })
1643 .unwrap_or_default()
1644 }
1645
1646 let s = resources.as_ref()?;
1647

Callers 1

extract_typed_resourcesFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected