Skip to main content

AspectRegistry

Struct AspectRegistry 

Source
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

Source

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()));
Source

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).

Source

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.

Source

pub fn count(&self) -> usize

Get the number of registered aspects.

Source

pub fn clear(&self)

Clear all registered aspects (useful for testing).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.