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

Method put_scoped_message

crates/openshell-server/src/persistence/mod.rs:343–368  ·  view source on GitHub ↗

Insert or update a protobuf message under an application-owned scope.

(
        &self,
        message: &T,
        scope: &str,
    )

Source from the content-addressed store, hash-verified

341
342 /// Insert or update a protobuf message under an application-owned scope.
343 pub async fn put_scoped_message<
344 T: Message + ObjectType + ObjectId + ObjectName + ObjectLabels,
345 >(
346 &self,
347 message: &T,
348 scope: &str,
349 ) -> PersistenceResult<()> {
350 let labels_map = message.object_labels();
351 let labels_json = if labels_map.as_ref().is_none_or(HashMap::is_empty) {
352 None
353 } else {
354 Some(serde_json::to_string(&labels_map).map_err(|e| {
355 PersistenceError::Encode(format!("failed to serialize labels: {e}"))
356 })?)
357 };
358
359 self.put_scoped(
360 T::object_type(),
361 message.object_id(),
362 message.object_name(),
363 scope,
364 &message.encode_to_vec(),
365 labels_json.as_deref(),
366 )
367 .await
368 }
369
370 /// Fetch and decode a protobuf message by id.
371 pub async fn get_message<T: Message + Default + ObjectType + SetResourceVersion>(

Callers 1

put_refresh_stateFunction · 0.80

Calls 4

object_labelsMethod · 0.80
object_idMethod · 0.80
object_nameMethod · 0.80
put_scopedMethod · 0.45

Tested by

no test coverage detected