Skip to main content

DiffBlock

Struct DiffBlock 

Source
#[non_exhaustive]
pub struct DiffBlock { pub changes: Vec<FileChange>, }
Expand description

A block rendering generator or fixer file changes.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§changes: Vec<FileChange>

Implementations§

Source§

impl DiffBlock

Source

pub fn new() -> Self

Creates a new empty diff block.

Examples found in repository?
examples/report_demo.rs (line 70)
6fn main() {
7    let console = Console::stdout(ColorMode::Auto);
8
9    println!("=== 1. Verdict & Status ===");
10    println!(
11        "{}",
12        Verdict::Passed.render(console, "Configuration validated cleanly")
13    );
14    println!(
15        "{}",
16        Verdict::Warning.render(console, "3 non-critical findings detected")
17    );
18    println!(
19        "{}",
20        Verdict::Failed.render(console, "Build failed: 2 errors")
21    );
22    println!();
23
24    println!("=== 2. Error / Prerequisite Block ===");
25    let err_block = ErrorBlock::new("Required toolchain is unavailable")
26        .with_explanation("The configured version is not installed.")
27        .with_remedy("Install the required toolchain:")
28        .add_command("toolchain install stable");
29    print!("{}", err_block.render(console));
30
31    println!("=== 3. Decision-Oriented Report (Compact) ===");
32    let report = Report::new("Site audit v1.2.0", Verdict::Warning)
33        .add_scope_note(ScopeNote::new(
34            "Scope warnings",
35            vec![
36                "Git history partial".to_string(),
37                "1 file skipped".to_string(),
38            ],
39        ))
40        .add_metric(Metric::new("Errors", "0"))
41        .add_metric(Metric::new("Warnings", "4").with_trend(runemark::Trend::Negative, "+2"))
42        .add_metric(Metric::new("Score", "94/100").with_trend(runemark::Trend::Positive, "+5%"))
43        .add_group(
44            FindingGroup::new("Accessibility Violations")
45                .add_finding(
46                    Finding::new(runemark::Tone::Warning, "Image missing alt attribute")
47                        .with_rule_id("a11y/img-alt")
48                        .with_badge(runemark::Badge::quick_win())
49                        .with_confidence(runemark::Confidence::High)
50                        .with_location(Location::file_line_col("src/pages/index.astro", 42, 10))
51                        .with_remedy("Add alt=\"...\" description to <img> tag"),
52                )
53                .add_finding(
54                    Finding::new(runemark::Tone::Warning, "Low contrast ratio on hero button")
55                        .with_rule_id("a11y/contrast")
56                        .with_location(Location::file_line("src/components/Hero.astro", 18)),
57                ),
58        )
59        .add_next_step(
60            NextStep::new("Run auto-fixer for formatting issues").with_command("audit --fix"),
61        );
62
63    print!("{}", report.render(console));
64
65    println!("=== 4. Detailed Report View ===");
66    let detailed_report = report.with_detail_level(DetailLevel::Detailed);
67    print!("{}", detailed_report.render(console));
68
69    println!("=== 5. Generator Diff View ===");
70    let diff = DiffBlock::new()
71        .add_change(
72            FileChange::new(FileAction::Added, "src/components/Footer.astro").with_delta("+1.2 kB"),
73        )
74        .add_change(FileChange::new(
75            FileAction::Modified,
76            "src/layouts/Layout.astro",
77        ))
78        .add_change(FileChange::new(
79            FileAction::Deleted,
80            "src/legacy/Footer.jsx",
81        ));
82    print!("{}", diff.render(console));
83}
Source

pub fn add_change(self, change: FileChange) -> Self

Adds a file change to the block.

Examples found in repository?
examples/report_demo.rs (lines 71-73)
6fn main() {
7    let console = Console::stdout(ColorMode::Auto);
8
9    println!("=== 1. Verdict & Status ===");
10    println!(
11        "{}",
12        Verdict::Passed.render(console, "Configuration validated cleanly")
13    );
14    println!(
15        "{}",
16        Verdict::Warning.render(console, "3 non-critical findings detected")
17    );
18    println!(
19        "{}",
20        Verdict::Failed.render(console, "Build failed: 2 errors")
21    );
22    println!();
23
24    println!("=== 2. Error / Prerequisite Block ===");
25    let err_block = ErrorBlock::new("Required toolchain is unavailable")
26        .with_explanation("The configured version is not installed.")
27        .with_remedy("Install the required toolchain:")
28        .add_command("toolchain install stable");
29    print!("{}", err_block.render(console));
30
31    println!("=== 3. Decision-Oriented Report (Compact) ===");
32    let report = Report::new("Site audit v1.2.0", Verdict::Warning)
33        .add_scope_note(ScopeNote::new(
34            "Scope warnings",
35            vec![
36                "Git history partial".to_string(),
37                "1 file skipped".to_string(),
38            ],
39        ))
40        .add_metric(Metric::new("Errors", "0"))
41        .add_metric(Metric::new("Warnings", "4").with_trend(runemark::Trend::Negative, "+2"))
42        .add_metric(Metric::new("Score", "94/100").with_trend(runemark::Trend::Positive, "+5%"))
43        .add_group(
44            FindingGroup::new("Accessibility Violations")
45                .add_finding(
46                    Finding::new(runemark::Tone::Warning, "Image missing alt attribute")
47                        .with_rule_id("a11y/img-alt")
48                        .with_badge(runemark::Badge::quick_win())
49                        .with_confidence(runemark::Confidence::High)
50                        .with_location(Location::file_line_col("src/pages/index.astro", 42, 10))
51                        .with_remedy("Add alt=\"...\" description to <img> tag"),
52                )
53                .add_finding(
54                    Finding::new(runemark::Tone::Warning, "Low contrast ratio on hero button")
55                        .with_rule_id("a11y/contrast")
56                        .with_location(Location::file_line("src/components/Hero.astro", 18)),
57                ),
58        )
59        .add_next_step(
60            NextStep::new("Run auto-fixer for formatting issues").with_command("audit --fix"),
61        );
62
63    print!("{}", report.render(console));
64
65    println!("=== 4. Detailed Report View ===");
66    let detailed_report = report.with_detail_level(DetailLevel::Detailed);
67    print!("{}", detailed_report.render(console));
68
69    println!("=== 5. Generator Diff View ===");
70    let diff = DiffBlock::new()
71        .add_change(
72            FileChange::new(FileAction::Added, "src/components/Footer.astro").with_delta("+1.2 kB"),
73        )
74        .add_change(FileChange::new(
75            FileAction::Modified,
76            "src/layouts/Layout.astro",
77        ))
78        .add_change(FileChange::new(
79            FileAction::Deleted,
80            "src/legacy/Footer.jsx",
81        ));
82    print!("{}", diff.render(console));
83}
Source

pub fn render(&self, console: Console) -> String

Renders the diff block.

Examples found in repository?
examples/report_demo.rs (line 82)
6fn main() {
7    let console = Console::stdout(ColorMode::Auto);
8
9    println!("=== 1. Verdict & Status ===");
10    println!(
11        "{}",
12        Verdict::Passed.render(console, "Configuration validated cleanly")
13    );
14    println!(
15        "{}",
16        Verdict::Warning.render(console, "3 non-critical findings detected")
17    );
18    println!(
19        "{}",
20        Verdict::Failed.render(console, "Build failed: 2 errors")
21    );
22    println!();
23
24    println!("=== 2. Error / Prerequisite Block ===");
25    let err_block = ErrorBlock::new("Required toolchain is unavailable")
26        .with_explanation("The configured version is not installed.")
27        .with_remedy("Install the required toolchain:")
28        .add_command("toolchain install stable");
29    print!("{}", err_block.render(console));
30
31    println!("=== 3. Decision-Oriented Report (Compact) ===");
32    let report = Report::new("Site audit v1.2.0", Verdict::Warning)
33        .add_scope_note(ScopeNote::new(
34            "Scope warnings",
35            vec![
36                "Git history partial".to_string(),
37                "1 file skipped".to_string(),
38            ],
39        ))
40        .add_metric(Metric::new("Errors", "0"))
41        .add_metric(Metric::new("Warnings", "4").with_trend(runemark::Trend::Negative, "+2"))
42        .add_metric(Metric::new("Score", "94/100").with_trend(runemark::Trend::Positive, "+5%"))
43        .add_group(
44            FindingGroup::new("Accessibility Violations")
45                .add_finding(
46                    Finding::new(runemark::Tone::Warning, "Image missing alt attribute")
47                        .with_rule_id("a11y/img-alt")
48                        .with_badge(runemark::Badge::quick_win())
49                        .with_confidence(runemark::Confidence::High)
50                        .with_location(Location::file_line_col("src/pages/index.astro", 42, 10))
51                        .with_remedy("Add alt=\"...\" description to <img> tag"),
52                )
53                .add_finding(
54                    Finding::new(runemark::Tone::Warning, "Low contrast ratio on hero button")
55                        .with_rule_id("a11y/contrast")
56                        .with_location(Location::file_line("src/components/Hero.astro", 18)),
57                ),
58        )
59        .add_next_step(
60            NextStep::new("Run auto-fixer for formatting issues").with_command("audit --fix"),
61        );
62
63    print!("{}", report.render(console));
64
65    println!("=== 4. Detailed Report View ===");
66    let detailed_report = report.with_detail_level(DetailLevel::Detailed);
67    print!("{}", detailed_report.render(console));
68
69    println!("=== 5. Generator Diff View ===");
70    let diff = DiffBlock::new()
71        .add_change(
72            FileChange::new(FileAction::Added, "src/components/Footer.astro").with_delta("+1.2 kB"),
73        )
74        .add_change(FileChange::new(
75            FileAction::Modified,
76            "src/layouts/Layout.astro",
77        ))
78        .add_change(FileChange::new(
79            FileAction::Deleted,
80            "src/legacy/Footer.jsx",
81        ));
82    print!("{}", diff.render(console));
83}

Trait Implementations§

Source§

impl Clone for DiffBlock

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DiffBlock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DiffBlock

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for DiffBlock

Source§

impl PartialEq for DiffBlock

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DiffBlock

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.