winrt-xaml 1.0.0

A Rust library for creating modern Windows UIs using WinRT and XAML with reactive data binding
Documentation
//! WinRT property access system.
//!
//! Provides helpers for getting and setting properties on WinRT objects.

use super::IInspectable;
use crate::error::Result;

/// Helper trait for WinRT property access.
pub trait PropertyAccess {
    /// Get the underlying IInspectable.
    fn inspectable(&self) -> &IInspectable;

    /// Try to get a string property.
    fn get_string_property(&self, property_name: &str) -> Result<String> {
        // This would use IInspectable to get the property
        // For MVP, return placeholder
        Ok(format!("<property:{}>", property_name))
    }

    /// Try to set a string property.
    fn set_string_property(&self, property_name: &str, value: &str) -> Result<()> {
        println!("   🔧 Setting {} = \"{}\"", property_name, value);
        // This would use IInspectable to set the property
        // For MVP, just log it
        Ok(())
    }

    /// Try to get a numeric property.
    fn get_numeric_property(&self, property_name: &str) -> Result<f64> {
        println!("   📊 Getting {} (placeholder)", property_name);
        Ok(0.0)
    }

    /// Try to set a numeric property.
    fn set_numeric_property(&self, property_name: &str, value: f64) -> Result<()> {
        println!("   🔧 Setting {} = {}", property_name, value);
        Ok(())
    }
}

/// Extension methods for common WinRT patterns.
pub trait WinRTObject: PropertyAccess {
    /// Get the runtime class name.
    fn runtime_class_name(&self) -> Result<String> {
        // Would call GetRuntimeClassName on IInspectable
        Ok("Windows.UI.Xaml.Object".to_string())
    }

    /// Check if this object supports a specific interface.
    fn supports_interface(&self, interface_name: &str) -> bool {
        println!("   🔍 Checking for interface: {}", interface_name);
        true // For MVP, assume yes
    }
}

// Blanket implementation for all PropertyAccess types
impl<T: PropertyAccess> WinRTObject for T {}