pub struct ImpactScore(/* private fields */);Expand description
Validated impact score representing error severity (0-1000).
§Purpose
This newtype centralizes impact validation and makes the type system encode security policy:
- Impact scores must be in valid range (0-1000)
- Construction enforces validation once at creation
- Downstream consumers receive pre-validated scores
§Copy Semantics
This type is Copy because:
- It’s a small numeric value (u16)
- No governance risk from duplication
- Defensive code benefits from pass-by-value semantics
§Feature: Strict Severity Authority
When strict_severity feature is enabled, additional constraints apply
based on namespace authority flags. See ErrorNamespace::CAN_BREACH.
§Example
// Compile-time validation
const MINOR_IMPACT: ImpactScore = ImpactScore::new(150);
// Runtime validation
let score = ImpactScore::checked_new(user_input).unwrap();Implementations§
Source§impl ImpactScore
impl ImpactScore
Sourcepub fn checked_new(score: u16) -> Result<Self, ImpactScoreError>
pub fn checked_new(score: u16) -> Result<Self, ImpactScoreError>
Sourcepub const fn to_impact_level(self) -> ErrorImpact
pub const fn to_impact_level(self) -> ErrorImpact
Convert to detailed impact level classification.
Sourcepub const fn is_breach_level(self) -> bool
pub const fn is_breach_level(self) -> bool
Check if this is a Breach-level impact (951-1000).
Trait Implementations§
Source§impl Clone for ImpactScore
impl Clone for ImpactScore
Source§fn clone(&self) -> ImpactScore
fn clone(&self) -> ImpactScore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ImpactScore
impl Debug for ImpactScore
Source§impl Display for ImpactScore
impl Display for ImpactScore
Source§impl Hash for ImpactScore
impl Hash for ImpactScore
Source§impl PartialEq for ImpactScore
impl PartialEq for ImpactScore
impl Copy for ImpactScore
impl Eq for ImpactScore
impl StructuralPartialEq for ImpactScore
Auto Trait Implementations§
impl Freeze for ImpactScore
impl RefUnwindSafe for ImpactScore
impl Send for ImpactScore
impl Sync for ImpactScore
impl Unpin for ImpactScore
impl UnwindSafe for ImpactScore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more