windows-api-utils 0.2.0

Windows API utilities for coordinate conversion, bit operations, and message parameter handling with feature gating
Documentation
//! Error types for Windows API utilities.
//!
//! This module provides error types that are always available,
//! regardless of which features are enabled.

#[cfg(feature = "std")]
use thiserror::Error;

/// Errors that can occur in Windows API utilities.
#[cfg_attr(feature = "std", derive(Error))]
#[cfg_attr(not(feature = "std"), derive(Debug, Clone, PartialEq))]
#[derive(Debug, Clone, PartialEq)]
pub enum WindowsUtilsError {
    /// Invalid coordinates provided.
    #[cfg_attr(feature = "std", error("Invalid coordinates: ({x}, {y})"))]
    InvalidCoordinates {
        /// X coordinate
        x: i32,
        /// Y coordinate
        y: i32,
    },

    /// Point is outside the window bounds.
    #[cfg_attr(feature = "std", error("Point ({x}, {y}) is outside window bounds"))]
    OutOfBounds {
        /// X coordinate
        x: i32,
        /// Y coordinate
        y: i32,
    },

    /// Invalid window handle.
    #[cfg_attr(feature = "std", error("Invalid window handle: {handle}"))]
    InvalidWindowHandle {
        /// Window handle
        handle: isize,
    },

    /// Invalid message parameter.
    #[cfg_attr(feature = "std", error("Invalid message parameter: {parameter}"))]
    InvalidMessageParameter {
        /// Parameter description
        parameter: &'static str, // Changed from String to &'static str for no_std
    },

    /// Unsupported message type.
    #[cfg_attr(feature = "std", error("Unsupported message type: 0x{message:x}"))]
    UnsupportedMessage {
        /// Message ID
        message: u32,
    },

    /// Feature not enabled.
    #[cfg_attr(feature = "std", error("Required feature not enabled: {feature}"))]
    FeatureNotEnabled {
        /// Required feature name
        feature: &'static str,
    },
}

/// Result type for Windows API utilities.
pub type WindowsUtilsResult<T> = Result<T, WindowsUtilsError>;