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>>)
| 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 | match op { |
| 28 | GraphOp::FileAdd { |
| 29 | add_name, |
| 30 | add_inode, |
| 31 | contents, |
| 32 | path, |
| 33 | encoding, |
| 34 | } => Ok(CompactGraphOp::FileAdd { |
| 35 | add_name: self.compact_insertion(add_name)?, |
| 36 | add_inode: self.compact_insertion(add_inode)?, |
| 37 | contents: contents |
| 38 | .as_ref() |
| 39 | .map(|c| self.compact_insertion(c)) |
| 40 | .transpose()?, |
| 41 | path: path.clone(), |
| 42 | encoding: *encoding, |
| 43 | }), |
| 44 | |
| 45 | GraphOp::DirAdd { |
| 46 | add_name, |
| 47 | add_inode, |
| 48 | path, |
| 49 | } => Ok(CompactGraphOp::DirAdd { |
| 50 | add_name: self.compact_insertion(add_name)?, |
| 51 | add_inode: self.compact_insertion(add_inode)?, |
| 52 | path: path.clone(), |
| 53 | }), |
| 54 | |
| 55 | GraphOp::DirDel { del, path } => Ok(CompactGraphOp::DirDel { |
| 56 | del: self.compact_edge_update(del)?, |
| 57 | path: path.clone(), |
| 58 | }), |
| 59 | |
| 60 | GraphOp::DirUndel { undel, path } => Ok(CompactGraphOp::DirUndel { |
| 61 | undel: self.compact_edge_update(undel)?, |
| 62 | path: path.clone(), |
| 63 | }), |
| 64 | |
| 65 | GraphOp::FileDel { |
| 66 | del, |
| 67 | contents, |
| 68 | path, |
| 69 | encoding, |
| 70 | } => Ok(CompactGraphOp::FileDel { |
| 71 | del: self.compact_edge_update(del)?, |
| 72 | contents: contents |
| 73 | .as_ref() |
| 74 | .map(|c| self.compact_edge_update(c)) |
| 75 | .transpose()?, |
| 76 | path: path.clone(), |
| 77 | encoding: *encoding, |
| 78 | }), |
| 79 | |
| 80 | GraphOp::FileUndel { |
| 81 | undel, |
| 82 | contents, |
| 83 | path, |