MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / slice_from_proto

Function slice_from_proto

libatomic/src/daemon/sandbox_wire.rs:212–236  ·  view source on GitHub ↗
(slice: &pb::SandboxSlice)

Source from the content-addressed store, hash-verified

210}
211
212pub fn slice_from_proto(slice: &pb::SandboxSlice) -> Result<SandboxSlice, String> {
213 let spans = slice
214 .content_spans
215 .iter()
216 .map(|span| {
217 if span.length != span.content.len() as u64 {
218 return Err(format!(
219 "a span says {} bytes and carries {}",
220 span.length,
221 span.content.len()
222 ));
223 }
224 Ok(SpanBytes {
225 change: hash_from_proto(span.change.as_ref())?,
226 start: span.offset,
227 bytes: span.content.clone(),
228 })
229 })
230 .collect::<Result<Vec<_>, String>>()?;
231 SandboxSlice::from_parts(
232 payload(slice.graph_slice.as_ref(), SANDBOX_GRAPH_SLICE_SCHEMA)?,
233 spans,
234 )
235 .map_err(|e| e.to_string())
236}
237
238/// A refusal as the contract's [`pb::ErrorInfo`]: `VIEW_STALE` for a stale
239/// view, `CHANGE_REJECTED` otherwise, with the variant in

Callers 2

file_statesMethod · 0.85
file_statesMethod · 0.85

Calls 6

hash_from_protoFunction · 0.85
payloadFunction · 0.85
as_refMethod · 0.80
iterMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45

Tested by 1

file_statesMethod · 0.68