Skip to main content

RegisteredDiagnostic

Struct RegisteredDiagnostic 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn location(self, span: SourceSpan) -> Self

Sets the source span. UNKNOWN_SPAN is treated as “no location”.

Source

pub fn suggested_fix(self, suggested_fix: Option<impl Into<String>>) -> Self

Sets an optional suggested fix.

Source

pub fn condition_scenario( self, condition_scenario: Option<HashMap<String, bool>>, ) -> Self

Sets the condition scenario under which the diagnostic applies.

Source

pub fn phase(self, phase: Phase) -> Self

Pins the pipeline phase. When left unset, downstream enrichment derives the phase from the rule’s severity.

Source

pub fn related_resources( self, related_resources: Option<Vec<RelatedResource>>, ) -> Self

Attaches related resource references (cross-resource findings).

Source

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.

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> 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, 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.