Skip to main content

advice

Attribute Macro advice 

Source
#[advice]
Expand description

Registers an aspect with a pointcut pattern for declarative aspect application.

§Example

use aspect_macros::advice;
use aspect_core::prelude::*;

#[advice(
    pointcut = "execution(pub fn *(..)) && within(crate::api)",
    advice = "around",
    order = 10
)]
fn api_logger(pjp: ProceedingJoinPoint) -> Result<Box<dyn Any>, AspectError> {
    println!("API call: {}", pjp.context().function_name);
    pjp.proceed()
}