Decode directly to typed graph operations with bounded collection/string allocations. No postcard replay buffer or repository database is required.
(payload: &[u8])
| 352 | /// Decode directly to typed graph operations with bounded collection/string |
| 353 | /// allocations. No postcard replay buffer or repository database is required. |
| 354 | pub 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 | |
| 376 | const _: () = { |
| 377 | assert!(std::mem::size_of::<CompactGraphOp>() <= 512); |