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

Function fetch_chunk

crates/openshell-supervisor-network/src/policy_local.rs:929–939  ·  view source on GitHub ↗

One gateway call: list the sandbox's draft chunks and find the matching id. Returns `Ok(None)` only when the gateway responded successfully but no chunk in this sandbox matches.

(
    session: &LookupSession<'_>,
    chunk_id: &str,
)

Source from the content-addressed store, hash-verified

927/// id. Returns `Ok(None)` only when the gateway responded successfully but
928/// no chunk in this sandbox matches.
929async fn fetch_chunk(
930 session: &LookupSession<'_>,
931 chunk_id: &str,
932) -> std::result::Result<Option<PolicyChunk>, (u16, serde_json::Value)> {
933 let chunks = session
934 .client
935 .get_draft_policy(session.sandbox_name, "")
936 .await
937 .map_err(|e| (502, error_payload("gateway_lookup_failed", e.to_string())))?;
938 Ok(chunks.into_iter().find(|c| c.id == chunk_id))
939}
940
941fn proposal_chunks_from_body(body: &[u8]) -> std::result::Result<Vec<PolicyChunk>, String> {
942 let request: ProposalRequest = serde_json::from_slice(body).map_err(|e| e.to_string())?;

Callers 2

proposal_wait_responseFunction · 0.85
fetch_chunk_or_404Function · 0.85

Calls 2

error_payloadFunction · 0.85
get_draft_policyMethod · 0.45

Tested by

no test coverage detected