ValidationReport

Struct ValidationReport 

Source
pub struct ValidationReport {
    pub collisions: Vec<PermissionCollision>,
}
Expand description

Validation outcome for a set of permission strings.

Produced by:

§Terminology

  • Duplicate permission: The exact same string appears more than once. These are represented internally as a “collision” where every entry in the collision group is identical.
  • Hash collision: Two different normalized permission strings that deterministically hash (via the 64‑bit truncated SHA‑256) to the same ID. This is extremely unlikely and should be treated as a critical configuration problem if it ever occurs.

§Interpreting Results

  • ValidationReport::is_valid is true when there are no collisions at all (neither duplicates nor distinct-string collisions).
  • ValidationReport::duplicates returns only pure duplicates (all strings in the collision set are identical).
  • Distinct collisions (same hash, different strings) are considered more severe and will appear in log output / detailed_errors but not in duplicates().

§Typical Actions

SituationActionSeverity
Report is validProceed with startup / reloadNone
One or more duplicates onlyRemove redundant entries (usually a config hygiene issue)Low / Medium
Any non‑duplicate hash collision detectedRename at least one colliding permission (treat as urgent)High (very rare)

§Convenience Methods

  • summary gives a compact human‑readable description (good for logs / errors).
  • detailed_errors enumerates each issue (useful for API / CLI feedback).
  • total_issues counts total collision groups (duplicates + distinct collisions).

§Example

use axum_gate::permissions::{PermissionCollisionChecker, ApplicationValidator};

// Direct checker
let mut checker = PermissionCollisionChecker::new(vec![
    "user:read".into(),
    "user:read".into(),      // duplicate
    "admin:full".into(),
]);
let report = checker.validate().unwrap();
assert!(!report.is_valid());
assert_eq!(report.duplicates(), vec!["user:read".to_string()]);

// Builder style
let report2 = ApplicationValidator::new()
    .add_permissions(["user:read", "user:read"])
    .validate()
    .unwrap();
assert!(!report2.is_valid());

§Performance Notes

The validator groups by 64‑bit IDs first; memory usage is proportional to the number of distinct permission IDs plus total string storage. For typical application-scale permission sets (≪10k) this is negligible.

§Logging

Use log_results for structured tracing output. Successful validation logs at INFO, issues at WARN.

Fields§

§collisions: Vec<PermissionCollision>

All collision groups (duplicates and true hash collisions).

Each entry contains:

  • The 64‑bit permission ID (id)
  • The list of original permission strings that map to that ID

Invariants:

  • Length >= 2 for each permissions vector
  • A “duplicate” group has every element string-equal
  • A “distinct collision” group has at least one differing string

Implementations§

Source§

impl ValidationReport

Source

pub fn is_valid(&self) -> bool

Returns true if validation passed without any issues.

A validation is considered successful if there are no hash collisions.

Source

pub fn duplicates(&self) -> Vec<String>

Returns duplicate permission strings found.

Duplicates are derived from collisions where all permissions are identical.

Source

pub fn summary(&self) -> String

Returns a human-readable summary of validation results.

For successful validations, returns a success message. For failed validations, provides details about what issues were found.

Source

pub fn log_results(&self)

Logs validation results using the tracing crate.

This method will log at INFO level for successful validations and WARN level for any issues found.

Source

pub fn detailed_errors(&self) -> Vec<String>

Returns detailed information about all issues found.

This method provides comprehensive details suitable for debugging or detailed error reporting.

Source

pub fn total_issues(&self) -> usize

Returns the total number of issues found.

Trait Implementations§

Source§

impl Debug for ValidationReport

Source§

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

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

impl Default for ValidationReport

Source§

fn default() -> ValidationReport

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

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,