pub struct AspectRegistry { /* private fields */ }Expand description
Global aspect registry for managing aspect-pointcut bindings.
The registry is thread-safe and can be accessed from anywhere in the program. Aspects are matched against functions using their pointcut patterns.
Implementations§
Source§impl AspectRegistry
impl AspectRegistry
Sourcepub fn register(
&self,
aspect: Arc<dyn Aspect>,
pointcut: Pointcut,
order: i32,
name: Option<String>,
)
pub fn register( &self, aspect: Arc<dyn Aspect>, pointcut: Pointcut, order: i32, name: Option<String>, )
Register an aspect with a pointcut pattern.
§Example
use aspect_runtime::registry::global_registry;
use aspect_core::pointcut::Pointcut;
use std::sync::Arc;
// Register an aspect (my_aspect would be an actual Aspect implementation)
let pointcut = Pointcut::parse("execution(pub fn *(..))").unwrap();
// global_registry().register(Arc::new(my_aspect), pointcut, 0, Some("my_aspect".into()));Sourcepub fn find_matching(&self, function: &FunctionInfo) -> Vec<RegisteredAspect>
pub fn find_matching(&self, function: &FunctionInfo) -> Vec<RegisteredAspect>
Find all aspects that match the given function.
Returns aspects in execution order (sorted by order field).
Sourcepub fn apply_aspects(
&self,
function: &FunctionInfo,
pjp: ProceedingJoinPoint<'_>,
) -> Result<Box<dyn Any>, AspectError>
pub fn apply_aspects( &self, function: &FunctionInfo, pjp: ProceedingJoinPoint<'_>, ) -> Result<Box<dyn Any>, AspectError>
Apply all matching aspects to a function execution.
This creates a chain of aspects, with lower-order aspects wrapping higher-order ones.
Auto Trait Implementations§
impl !Freeze for AspectRegistry
impl RefUnwindSafe for AspectRegistry
impl Send for AspectRegistry
impl Sync for AspectRegistry
impl Unpin for AspectRegistry
impl UnsafeUnpin for AspectRegistry
impl UnwindSafe for AspectRegistry
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