pub struct ValidationReport {
pub collisions: Vec<PermissionCollision>,
}Expand description
Validation outcome for a set of permission strings.
This is the main result type returned by permission validation APIs. It tells you whether the permission set is safe to use and, if not, what needs to be fixed.
Produced by:
collision_checker::PermissionCollisionChecker::validateapplication_validator::ApplicationValidator::validate
§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 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_validistruewhen there are no collisions at all.ValidationReport::duplicatesreturns only pure duplicates.- Distinct collisions are more severe and appear in log output and
ValidationReport::detailed_errors.
§Typical Actions
| Situation | Action | Severity |
|---|---|---|
| Report is valid | Proceed with startup or reload | None |
| One or more duplicates only | Remove redundant entries | Low or medium |
| Any non-duplicate hash collision | Rename at least one colliding permission immediately | High |
§Convenience Methods
ValidationReport::summaryreturns a compact human-readable description.ValidationReport::detailed_errorsreturns issue-by-issue diagnostics.ValidationReport::total_issuesreturns the number of collision groups.
§Example
use webgates_core::permissions::application_validator::ApplicationValidator;
use webgates_core::permissions::collision_checker::PermissionCollisionChecker;
let mut checker = PermissionCollisionChecker::new(vec![
"user:read".into(),
"user:read".into(),
"admin:full".into(),
]);
let report = checker.validate().map_err(|err| err.to_string())?;
assert!(!report.is_valid());
assert_eq!(report.duplicates(), vec!["user:read".to_string()]);
let report2 = ApplicationValidator::new()
.add_permissions(["user:read", "user:read"])
.validate()
.map_err(|err| err.to_string())?;
assert!(!report2.is_valid());§Logging
Use ValidationReport::log_results for structured tracing output. Successful
validation logs at INFO, and issues log 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
permissionsvector - A “duplicate” group has every element string-equal
- A “distinct collision” group has at least one differing string
Implementations§
Source§impl ValidationReport
impl ValidationReport
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns true when validation passed without any issues.
A report is valid when there are no duplicate groups and no true hash collisions.
Sourcepub fn duplicates(&self) -> Vec<String>
pub fn duplicates(&self) -> Vec<String>
Returns duplicate permission strings found in the report.
Duplicates are collision groups where all permission strings are identical.
Sourcepub fn summary(&self) -> String
pub fn summary(&self) -> String
Returns a human-readable summary of the validation result.
For successful validation, this returns a success message. For failed validation, it summarizes duplicates and true hash collisions.
Sourcepub fn log_results(&self)
pub fn log_results(&self)
Logs validation results using tracing.
Successful validation logs at INFO. Any duplicates or collisions log at WARN.
Sourcepub fn detailed_errors(&self) -> Vec<String>
pub fn detailed_errors(&self) -> Vec<String>
Returns detailed issue strings for debugging or reporting.
Sourcepub fn total_issues(&self) -> usize
pub fn total_issues(&self) -> usize
Returns the number of collision groups recorded in the report.