Skip to main content

Scanner

Trait Scanner 

Source
pub trait Scanner<App: Send + Sync = ()> {
    // Required methods
    fn scan<'life0, 'life1, 'async_trait>(
        &'life0 self,
        app: &'life1 App,
    ) -> Pin<Box<dyn Future<Output = Vec<ScannedModule>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn source_name(&self) -> &str;
}
Expand description

Abstract interface for framework scanners.

Implementors provide scan() for framework-specific endpoint scanning and source_name() for identification. The App type parameter allows each framework adapter to accept its own application type:

// Example: Axum adapter
struct AxumScanner;

#[async_trait]
impl Scanner<axum::Router> for AxumScanner {
    async fn scan(&self, app: &axum::Router) -> Vec<ScannedModule> { /* ... */ }
    fn source_name(&self) -> &str { "axum" }
}

// Example: Actix adapter
struct ActixScanner;

#[async_trait]
impl Scanner<()> for ActixScanner {
    async fn scan(&self, _app: &()) -> Vec<ScannedModule> { /* ... */ }
    fn source_name(&self) -> &str { "actix-web" }
}

Required Methods§

Source

fn scan<'life0, 'life1, 'async_trait>( &'life0 self, app: &'life1 App, ) -> Pin<Box<dyn Future<Output = Vec<ScannedModule>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Scan endpoints and return module definitions.

The app parameter receives framework-specific state (e.g., axum::Router, actix_web::App). Use () if no app context is needed.

Source

fn source_name(&self) -> &str

Return human-readable scanner name (e.g., “axum”, “actix-web”).

Implementors§