(node: &ChunkNode<'_>)
| 77 | } |
| 78 | |
| 79 | fn inspect_node(node: &ChunkNode<'_>) -> Result<ChunkInfo> { |
| 80 | let raw_meta = node.meta(); |
| 81 | let algo_id = raw_meta.compression_method(); |
| 82 | let algo_name = match algo_id { |
| 83 | 0 => "None".to_string(), |
| 84 | 1 => "LZ4".to_string(), |
| 85 | _ => format!("Unknown({})", algo_id), |
| 86 | }; |
| 87 | |
| 88 | let (hint, distrib) = Self::analyze_payload(node); |
| 89 | |
| 90 | let mut children_info = Vec::new(); |
| 91 | if node.child_count() > 0 { |
| 92 | let children = node.children()?; |
| 93 | for child in children { |
| 94 | children_info.push(Self::inspect_node(&child)?); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | Ok(ChunkInfo { |
| 99 | offset: node.offset(), |
| 100 | total_length: node.length(), |
| 101 | payload_size: node.payload_len(), |
| 102 | child_count: node.child_count(), |
| 103 | compression_algo: algo_name, |
| 104 | is_chunkable: raw_meta.is_chunkable(), |
| 105 | node_type_hint: hint, |
| 106 | distribution_info: distrib, |
| 107 | children: children_info, |
| 108 | }) |
| 109 | } |
| 110 | |
| 111 | fn analyze_payload(node: &ChunkNode<'_>) -> (String, Option<String>) { |
| 112 | if node.child_count() == 0 { |
nothing calls this directly
no test coverage detected