MCPcopy Create free account
hub / github.com/Mic92/nix-diff-rs / format_output_diff

Method format_output_diff

src/render.rs:189–239  ·  view source on GitHub ↗
(&self, output: &mut Vec<u8>, diff: &OutputDiff, indent: usize)

Source from the content-addressed store, hash-verified

187 }
188
189 fn format_output_diff(&self, output: &mut Vec<u8>, diff: &OutputDiff, indent: usize) {
190 self.write_indent(output, indent);
191 extend!(output, b"Output '", &diff.name, b"':\n");
192
193 match &diff.diff {
194 OutputDetailDiff::Added(out) => {
195 self.write_indent(output, indent + 2);
196 extend!(
197 output,
198 self.green(),
199 b"+ Added: ",
200 &out.path,
201 self.reset(),
202 b"\n"
203 );
204 }
205 OutputDetailDiff::Removed(out) => {
206 self.write_indent(output, indent + 2);
207 extend!(
208 output,
209 self.red(),
210 b"- Removed: ",
211 &out.path,
212 self.reset(),
213 b"\n"
214 );
215 }
216 OutputDetailDiff::Changed {
217 path,
218 hash_algo,
219 hash,
220 ..
221 } => {
222 if let Some(path_diff) = path {
223 self.write_indent(output, indent + 2);
224 extend!(output, b"Path:\n");
225 self.format_string_diff(output, path_diff, indent + 4);
226 }
227 if let Some(algo_diff) = hash_algo {
228 self.write_indent(output, indent + 2);
229 extend!(output, b"Hash algorithm:\n");
230 self.format_string_diff(output, algo_diff, indent + 4);
231 }
232 if let Some(hash_diff) = hash {
233 self.write_indent(output, indent + 2);
234 extend!(output, b"Hash:\n");
235 self.format_string_diff(output, hash_diff, indent + 4);
236 }
237 }
238 }
239 }
240
241 fn format_string_diff(&self, output: &mut Vec<u8>, diff: &StringDiff, indent: usize) {
242 let StringDiff { old, new } = diff;

Callers 1

Calls 2

write_indentMethod · 0.80
format_string_diffMethod · 0.80

Tested by

no test coverage detected