5 unstable releases

0.3.0 Mar 26, 2021
0.2.1 Sep 26, 2020
0.2.0 Aug 24, 2019
0.1.1 Feb 7, 2019
0.1.0 Feb 6, 2019

#1291 in Rust patterns

Download history 16857/week @ 2024-08-25 22038/week @ 2024-09-01 18547/week @ 2024-09-08 17194/week @ 2024-09-15 16616/week @ 2024-09-22 15289/week @ 2024-09-29 7132/week @ 2024-10-06 16400/week @ 2024-10-13 19367/week @ 2024-10-20 17976/week @ 2024-10-27 17996/week @ 2024-11-03 13109/week @ 2024-11-10 19688/week @ 2024-11-17 22254/week @ 2024-11-24 27028/week @ 2024-12-01 28428/week @ 2024-12-08

97,632 downloads per month
Used in 5 crates (via metered)

Apache-2.0 OR MIT

14KB
157 lines

aspect-rs

Build Status License Cargo Documentation Rust 1.31+

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.

Changelog

  • 0.2.0:
    • Updated dependencies to use syn, proc-macro2 and quote 1.0

Required Rust version

Aspect-RS runs on Rust stable.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2.5MB
~54K SLoC