pub struct ValidationAspect { /* private fields */ }Expand description
Validation aspect for enforcing constraints.
Allows composing multiple validation rules that are checked before function execution.
§Example
ⓘ
use aspect_std::{ValidationAspect, ValidationRule};
use aspect_macros::aspect;
struct AgeValidator;
impl ValidationRule for AgeValidator {
fn validate(&self, ctx: &JoinPoint) -> Result<(), String> {
// Validation logic
Ok(())
}
}
let validator = ValidationAspect::new()
.add_rule(Box::new(AgeValidator));
#[aspect(validator)]
fn set_age(age: i32) -> Result<(), String> {
Ok(())
}Implementations§
Trait Implementations§
Source§impl Aspect for ValidationAspect
impl Aspect for ValidationAspect
Source§fn around(
&self,
pjp: ProceedingJoinPoint<'_>,
) -> Result<Box<dyn Any>, AspectError>
fn around( &self, pjp: ProceedingJoinPoint<'_>, ) -> Result<Box<dyn Any>, AspectError>
Advice that wraps the entire target function execution. Read more
Source§fn after(&self, _ctx: &JoinPoint, _result: &(dyn Any + 'static))
fn after(&self, _ctx: &JoinPoint, _result: &(dyn Any + 'static))
Advice executed after the target function completes successfully. Read more
Source§fn after_error(&self, _ctx: &JoinPoint, _error: &AspectError)
fn after_error(&self, _ctx: &JoinPoint, _error: &AspectError)
Advice executed when the target function encounters an error. Read more
Auto Trait Implementations§
impl Freeze for ValidationAspect
impl !RefUnwindSafe for ValidationAspect
impl Send for ValidationAspect
impl Sync for ValidationAspect
impl Unpin for ValidationAspect
impl UnsafeUnpin for ValidationAspect
impl !UnwindSafe for ValidationAspect
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