auditmysite 1.4.0

Resource-efficient WCAG 2.1 AA (+ select 2.2 criteria) Accessibility Checker in Rust
Documentation
//! `AuditModule` implementation for UX collection (#332).
//!
//! UX is computed synchronously from the AX tree. Gated on
//! `check_seo || check_mobile` to match today's behavior.

use async_trait::async_trait;

use crate::audit::module::{AuditModule, ModuleContext, ModuleData};
use crate::audit::PipelineConfig;
use crate::error::Result;

use super::analyze_ux;

pub struct UxModule;

#[async_trait]
impl AuditModule for UxModule {
    fn id(&self) -> &'static str {
        "ux"
    }

    fn label(&self) -> &'static str {
        "UX"
    }

    fn is_enabled(&self, cfg: &PipelineConfig) -> bool {
        cfg.check_seo || cfg.check_mobile
    }

    async fn collect(&self, ctx: &ModuleContext<'_>) -> Result<ModuleData> {
        let ux = analyze_ux(ctx.ax_tree);
        Ok(ModuleData::Ux(Box::new(ux)))
    }
}