archunit

Enum Violation

Source
#[non_exhaustive]
pub enum Violation { EmptyTest(EmptyTestViolation), Cycle(CycleViolation), FilePattern(FilePatternViolation), FileDependency(FileDependencyViolation), ExternalModuleDependency(ExternalModuleDependencyViolation), CustomFile(CustomFileViolation), LayerDependency(LayerDependencyViolation), SliceDependency(SliceDependencyViolation), MetricZone(MetricZoneViolation), CustomMetric(CustomMetricViolation), MetricThreshold(MetricThresholdViolation), MetricPredicate(MetricPredicateViolation), }
Expand description

One data-carrying disagreement between a project and an architecture rule.

A complete rule result is Vec<Violation>: an empty vector means the rule passed. This enum deliberately contains no user-facing prose; the testing layer formats each variant later.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

EmptyTest(EmptyTestViolation)

The rule selected no subject and therefore could not judge its predicate.

§

Cycle(CycleViolation)

A circular path exists in the selected projected graph.

§

FilePattern(FilePatternViolation)

A file disagrees with a name or location predicate.

§

FileDependency(FileDependencyViolation)

An internal dependency disagrees with a relational file rule.

§

ExternalModuleDependency(ExternalModuleDependencyViolation)

An external crate dependency disagrees with a relational file rule.

§

CustomFile(CustomFileViolation)

A file disagrees with a user-defined predicate.

§

LayerDependency(LayerDependencyViolation)

An internal dependency disagrees with a named-layer policy.

§

SliceDependency(SliceDependencyViolation)

A projected dependency disagrees with a slice policy.

§

MetricZone(MetricZoneViolation)

A file component lies inside a discouraged metrics zone.

§

CustomMetric(CustomMetricViolation)

A user-defined type metric did not satisfy its predicate.

§

MetricThreshold(MetricThresholdViolation)

A metric value did not meet an exact numeric threshold.

§

MetricPredicate(MetricPredicateViolation)

A built-in metric value did not satisfy a user predicate.

Implementations§

Source§

impl Violation

Source

pub const fn kind(&self) -> ViolationKind

Returns this violation’s stable family.

Source

pub const fn as_empty_test(&self) -> Option<&EmptyTestViolation>

Returns the empty-test data when this is an empty-test violation.

Source

pub const fn as_cycle(&self) -> Option<&CycleViolation>

Returns the cycle data when this is a cycle violation.

Source

pub const fn as_file_pattern(&self) -> Option<&FilePatternViolation>

Returns the file-pattern data when this is a file-pattern violation.

Source

pub const fn as_file_dependency(&self) -> Option<&FileDependencyViolation>

Returns the file-dependency data when this is a file-dependency violation.

Source

pub const fn as_external_module_dependency( &self, ) -> Option<&ExternalModuleDependencyViolation>

Returns the external-module data when this is an external-module dependency violation.

Source

pub const fn as_custom_file(&self) -> Option<&CustomFileViolation>

Returns the custom-file data when this is a custom predicate violation.

Source

pub const fn as_layer_dependency(&self) -> Option<&LayerDependencyViolation>

Returns the named-layer dependency data when this is a layer violation.

Source

pub const fn as_slice_dependency(&self) -> Option<&SliceDependencyViolation>

Returns the projected slice dependency data when this is a slice violation.

Source

pub const fn as_metric_zone(&self) -> Option<&MetricZoneViolation>

Returns metric-zone data when this is a distance-zone violation.

Source

pub const fn as_custom_metric(&self) -> Option<&CustomMetricViolation>

Returns custom-metric data when a user predicate rejected a type value.

Source

pub const fn as_metric_threshold(&self) -> Option<&MetricThresholdViolation>

Returns numeric threshold data when a metric value missed its boundary.

Source

pub const fn as_metric_predicate(&self) -> Option<&MetricPredicateViolation>

Returns built-in metric predicate data when a callback rejected a value.

Trait Implementations§

Source§

impl Clone for Violation

Source§

fn clone(&self) -> Violation

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Violation

Source§

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

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

impl From<CustomFileViolation> for Violation

Source§

fn from(violation: CustomFileViolation) -> Self

Converts to this type from the input type.
Source§

impl From<CustomMetricViolation> for Violation

Source§

fn from(violation: CustomMetricViolation) -> Self

Converts to this type from the input type.
Source§

impl From<CycleViolation> for Violation

Source§

fn from(violation: CycleViolation) -> Self

Converts to this type from the input type.
Source§

impl From<EmptyTestViolation> for Violation

Source§

fn from(violation: EmptyTestViolation) -> Self

Converts to this type from the input type.
Source§

impl From<ExternalModuleDependencyViolation> for Violation

Source§

fn from(violation: ExternalModuleDependencyViolation) -> Self

Converts to this type from the input type.
Source§

impl From<FileDependencyViolation> for Violation

Source§

fn from(violation: FileDependencyViolation) -> Self

Converts to this type from the input type.
Source§

impl From<FilePatternViolation> for Violation

Source§

fn from(violation: FilePatternViolation) -> Self

Converts to this type from the input type.
Source§

impl From<LayerDependencyViolation> for Violation

Source§

fn from(violation: LayerDependencyViolation) -> Self

Converts to this type from the input type.
Source§

impl From<MetricPredicateViolation> for Violation

Source§

fn from(violation: MetricPredicateViolation) -> Self

Converts to this type from the input type.
Source§

impl From<MetricThresholdViolation> for Violation

Source§

fn from(violation: MetricThresholdViolation) -> Self

Converts to this type from the input type.
Source§

impl From<MetricZoneViolation> for Violation

Source§

fn from(violation: MetricZoneViolation) -> Self

Converts to this type from the input type.
Source§

impl From<SliceDependencyViolation> for Violation

Source§

fn from(violation: SliceDependencyViolation) -> Self

Converts to this type from the input type.

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.