pub struct RegisteredDiagnostic { /* private fields */ }Expand description
Builds a Diagnostic for a rule that is registered in the rule registry.
Severity, category, origin, and description are taken from the registry entry
for rule_id - this is the single place those four fields are sourced for
built-in diagnostics, so every built-in finding is consistent regardless of
which crate produced it. build panics if the rule is not
registered, turning an unregistered built-in rule into a loud failure instead
of a silently inconsistent diagnostic.
Custom and Guard rules are intentionally absent from the registry; they carry their own severity, category, and origin from the parsed rule definition and must construct diagnostics directly rather than through this builder.
Implementations§
Source§impl RegisteredDiagnostic
impl RegisteredDiagnostic
Sourcepub fn new(rule_id: impl Into<String>, message: impl Into<String>) -> Self
pub fn new(rule_id: impl Into<String>, message: impl Into<String>) -> Self
Starts a diagnostic for rule_id carrying message. All other fields
default to absent and are added through the builder methods.
Sourcepub fn resource(
self,
resource_id: impl Into<String>,
resource_type: Option<String>,
) -> Self
pub fn resource( self, resource_id: impl Into<String>, resource_type: Option<String>, ) -> Self
Attaches the offending resource as the targeted entity: its logical ID
and, when known, its CloudFormation type. An empty ID is dropped so
callers can pass through an ID that may be blank - mirrors
property_path.
Sourcepub fn property_path(self, property_path: impl Into<String>) -> Self
pub fn property_path(self, property_path: impl Into<String>) -> Self
Records the property path within the resource. An empty path is ignored so callers can pass through a path that may be blank.
Sourcepub fn location(self, span: SourceSpan) -> Self
pub fn location(self, span: SourceSpan) -> Self
Sets the source span. UNKNOWN_SPAN is
treated as “no location”.
Sourcepub fn suggested_fix(self, suggested_fix: Option<impl Into<String>>) -> Self
pub fn suggested_fix(self, suggested_fix: Option<impl Into<String>>) -> Self
Sets an optional suggested fix.
Sourcepub fn condition_scenario(
self,
condition_scenario: Option<HashMap<String, bool>>,
) -> Self
pub fn condition_scenario( self, condition_scenario: Option<HashMap<String, bool>>, ) -> Self
Sets the condition scenario under which the diagnostic applies.
Sourcepub fn phase(self, phase: Phase) -> Self
pub fn phase(self, phase: Phase) -> Self
Pins the pipeline phase. When left unset, downstream enrichment derives the phase from the rule’s severity.
Attaches related resource references (cross-resource findings).
Sourcepub fn build(self) -> Diagnostic
pub fn build(self) -> Diagnostic
Assembles the Diagnostic, sourcing severity, category, origin, and
description from the rule registry. Panics if rule_id is not registered.