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

Method compact_graph_op

atomic-core/src/change/format_v3/compact/convert.rs:26–180  ·  view source on GitHub ↗

Convert a `GraphOp >` to a [`CompactGraphOp`]. This is the main entry point for compacting a full graph operation before serialization. It recursively compacts all nested positions, nodes, and hashes. # Errors Returns an error if any hash referenced by the graph operation is not found in the dedup table.

(&self, op: &GraphOp<Option<Hash>>)

Source from the content-addressed store, hash-verified

24 /// Returns an error if any hash referenced by the graph operation
25 /// is not found in the dedup table.
26 pub fn compact_graph_op(&self, op: &GraphOp<Option<Hash>>) -> FormatResult<CompactGraphOp> {
27 op.validate_serialized_name_conflict()
28 .map_err(|reason| FormatError::InvalidGraphOp {
29 operation: op.type_name(),
30 reason,
31 })?;
32 match op {
33 GraphOp::FileAdd {
34 add_name,
35 add_inode,
36 contents,
37 path,
38 encoding,
39 } => Ok(CompactGraphOp::FileAdd {
40 add_name: self.compact_insertion(add_name)?,
41 add_inode: self.compact_insertion(add_inode)?,
42 contents: contents
43 .as_ref()
44 .map(|c| self.compact_insertion(c))
45 .transpose()?,
46 path: path.clone(),
47 encoding: *encoding,
48 }),
49
50 GraphOp::DirAdd {
51 add_name,
52 add_inode,
53 path,
54 } => Ok(CompactGraphOp::DirAdd {
55 add_name: self.compact_insertion(add_name)?,
56 add_inode: self.compact_insertion(add_inode)?,
57 path: path.clone(),
58 }),
59
60 GraphOp::DirDel { del, path } => Ok(CompactGraphOp::DirDel {
61 del: self.compact_edge_update(del)?,
62 path: path.clone(),
63 }),
64
65 GraphOp::DirUndel { undel, path } => Ok(CompactGraphOp::DirUndel {
66 undel: self.compact_edge_update(undel)?,
67 path: path.clone(),
68 }),
69
70 GraphOp::FileDel {
71 del,
72 contents,
73 path,
74 encoding,
75 } => Ok(CompactGraphOp::FileDel {
76 del: self.compact_edge_update(del)?,
77 contents: contents
78 .as_ref()
79 .map(|c| self.compact_edge_update(c))
80 .transpose()?,
81 path: path.clone(),
82 encoding: *encoding,
83 }),

Calls 8

compact_insertionMethod · 0.80
as_refMethod · 0.80
compact_edge_updateMethod · 0.80
compact_atomMethod · 0.80
compact_positionMethod · 0.80
type_nameMethod · 0.45
cloneMethod · 0.45