pub struct ProceedingJoinPoint<'a> { /* private fields */ }Expand description
A proceeding joinpoint that can be used in “around” advice.
This type wraps the original function execution and allows aspects to control when (or if) the function runs.
§Example
use aspect_core::prelude::*;
use std::any::Any;
struct TimingAspect;
impl Aspect for TimingAspect {
fn around(&self, pjp: ProceedingJoinPoint) -> Result<Box<dyn Any>, AspectError> {
let start = std::time::Instant::now();
let result = pjp.proceed()?;
let elapsed = start.elapsed();
println!("Execution took: {:?}", elapsed);
Ok(result)
}
}Implementations§
Source§impl<'a> ProceedingJoinPoint<'a>
impl<'a> ProceedingJoinPoint<'a>
Sourcepub fn new<F>(f: F, context: JoinPoint) -> Self
pub fn new<F>(f: F, context: JoinPoint) -> Self
Creates a new ProceedingJoinPoint.
§Parameters
f: The original function to executecontext: Information about the joinpoint
Sourcepub fn proceed(self) -> Result<Box<dyn Any>, AspectError>
pub fn proceed(self) -> Result<Box<dyn Any>, AspectError>
Proceeds with the original function execution.
This consumes the ProceedingJoinPoint and executes the wrapped function.
§Returns
The result of the function execution.
§Example
fn around(&self, pjp: ProceedingJoinPoint) -> Result<Box<dyn Any>, AspectError> {
println!("Before proceed");
let result = pjp.proceed()?;
println!("After proceed");
Ok(result)
}Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for ProceedingJoinPoint<'a>
impl<'a> !RefUnwindSafe for ProceedingJoinPoint<'a>
impl<'a> !Send for ProceedingJoinPoint<'a>
impl<'a> !Sync for ProceedingJoinPoint<'a>
impl<'a> Unpin for ProceedingJoinPoint<'a>
impl<'a> UnsafeUnpin for ProceedingJoinPoint<'a>
impl<'a> !UnwindSafe for ProceedingJoinPoint<'a>
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