rust_widgets 0.9.6

Pure Rust cross-platform native GUI library with hardware-adaptive rendering, 60+ widgets, touch/gesture support, i18n, and SVG-pipeline-accurate output
//! Control backend abstraction for native and custom-painted control paths.
//!
//! AUTO-GENERATED by tools/split_control_backend.py — do not edit manually.
//! Generated from implementation.rs.

pub mod custom;
pub mod dispatcher;
pub mod native;
pub mod routing;
pub mod trait_def;
pub mod types;

// Re-export key public types for backward compatibility.
#[cfg(feature = "controls-custom")]
pub use custom::CustomPaintControlBackend;
pub use dispatcher::{active_control_policy, get_control_backend, get_control_backend_for_widget};
pub use native::NativeControlBackend;
pub use routing::route_preference_for_widget_kind;
pub use trait_def::ControlBackend;
pub use types::{ControlBackendKind, ControlRoutePreference};

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn control_backend_kind_re_exported() {
        let _native = ControlBackendKind::Native;
        let _custom = ControlBackendKind::Custom;
        assert_ne!(_native, _custom);
    }

    #[test]
    fn control_route_preference_re_exported() {
        let _native_pref = ControlRoutePreference::NativePreferred;
        let _custom_req = ControlRoutePreference::CustomRequired;
        assert_ne!(_native_pref, _custom_req);
    }

    #[test]
    fn route_preference_for_widget_kind_re_exported() {
        use crate::widget::WidgetKind;
        let pref = route_preference_for_widget_kind(WidgetKind::Button);
        assert_eq!(pref, ControlRoutePreference::NativePreferred);
    }

    #[test]
    fn control_backend_trait_re_exported() {
        // ControlBackend is a trait — verify it can be used as a trait object.
        fn _take_trait_object(_: &dyn ControlBackend) {}
        let _ = _take_trait_object;
    }

    #[test]
    fn native_control_backend_re_exported() {
        let backend = NativeControlBackend::new();
        assert_eq!(backend.backend_name(), "native-control-backend");
    }

    #[test]
    fn dispatcher_functions_re_exported() {
        let backend = get_control_backend();
        assert!(!backend.backend_name().is_empty());
        let policy = active_control_policy();
        assert!(!policy.is_empty());
        use crate::widget::WidgetKind;
        let backend_for_widget = get_control_backend_for_widget(WidgetKind::Button);
        assert!(!backend_for_widget.backend_name().is_empty());
    }

    #[test]
    #[cfg(feature = "controls-custom")]
    fn custom_paint_control_backend_re_exported() {
        let backend = CustomPaintControlBackend::new();
        assert_eq!(backend.backend_name(), "custom-paint-control-backend");
    }
}