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

Function decode

atomic-core/src/change/format_v3/graph_fields/decode.rs:354–374  ·  view source on GitHub ↗

Decode directly to typed graph operations with bounded collection/string allocations. No postcard replay buffer or repository database is required.

(payload: &[u8])

Source from the content-addressed store, hash-verified

352/// Decode directly to typed graph operations with bounded collection/string
353/// allocations. No postcard replay buffer or repository database is required.
354pub fn decode(payload: &[u8]) -> FormatResult<GraphSectionPayload> {
355 let mut d = Decoder::parse(payload)?;
356 let n = d.count(512, d.control.len())?;
357 let mut ops = reserve(n)?;
358 for _ in 0..n {
359 ops.push(d.op()?);
360 }
361 if !d.control.is_empty()
362 || !d.aux.is_empty()
363 || d.columns.iter().any(|s| !s.data.is_empty() || s.count != 0)
364 || d.dictionary_end != d.dictionary.len()
365 {
366 return Err(invalid("unconsumed graph fields"));
367 }
368 Ok(GraphSectionPayload {
369 path: owned(d.path)?,
370 ops,
371 content_start: d.start,
372 content_end: d.end,
373 })
374}
375
376const _: () = {
377 assert!(std::mem::size_of::<CompactGraphOp>() <= 512);

Callers

nothing calls this directly

Calls 10

reserveFunction · 0.70
invalidFunction · 0.70
ownedFunction · 0.70
parseFunction · 0.50
countMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
opMethod · 0.45
is_emptyMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected