Expand description
§An Aspect Toolkit for Rust
Aspect-RS is a project aiming to provide common ground for the main Aspect-Oriented use cases in Rust. By leveraging the trait system, declarative and procedural macros, Aspect-RS provides blocks that let you wrap methods with your custom logic.
The project has been extracted from the Metered project, which uses the technique to build metrics that can work on expressions or methods, whether they’re async
or not. The technique seemed general enough to be in its own crate and see if it is of any interest to other parties.
Aspect-RS provides “pointcut” traits when entering or exiting an expression (OnEnter
and OnResult
), experimental Update
and UpdateRef
traits that can use parameter shadowing to intercept and update method parameters, and weaving constructs useful when building procedural macros. Please look at the Metered project to see Aspect-RS in action.
Modules§
- update
- An experimental module providing a way to update method parameters in aspects.
Enums§
- Advice
- An
Advice
describes what the aspect should do on return
Traits§
- Enter
- The
Enter
trait is called when entering in an aspect, before the wrapped expression is called. - OnResult
- The
OnResult
trait is implemented on Aspects to get notified when an expression has returned. - OnResult
Mut - The
OnResult
trait is implemented on Aspects to get notified when an expression has returned, and provide the possibility to alter the result. - Weave
- A trait to “Weave” an
impl
block, that is update each annotated method with your custom logic