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

Function decode_record

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

Decode a single [`ObjectRecord`] into a protobuf message, hydrating `resource_version` from the authoritative DB row. Extracted to avoid repeating the identical decode-and-hydrate block across `get_message`, `get_message_by_name`, `list_messages`, and `list_messages_with_selector`.

(
    record: ObjectRecord,
)

Source from the content-addressed store, hash-verified

143/// `get_message`, `get_message_by_name`, `list_messages`, and
144/// `list_messages_with_selector`.
145fn decode_record<T: Message + Default + SetResourceVersion>(
146 record: ObjectRecord,
147) -> PersistenceResult<T> {
148 let mut message = T::decode(record.payload.as_slice())
149 .map_err(|e| PersistenceError::Decode(format!("protobuf decode error: {e}")))?;
150 message.set_resource_version(record.resource_version);
151 Ok(message)
152}
153
154/// Dispatch a method call to the underlying store implementation.
155///

Callers

nothing calls this directly

Calls 2

as_sliceMethod · 0.80
set_resource_versionMethod · 0.80

Tested by

no test coverage detected