Skip to main content

mtl_gpu/enums/
log.rs

1//! Log state enumerations.
2//!
3//! Corresponds to `Metal/MTLLogState.hpp`.
4
5use mtl_foundation::{Integer, UInteger};
6
7// ============================================================================
8// LogLevel
9// ============================================================================
10
11/// Log verbosity level.
12///
13/// C++ equivalent: `MTL::LogLevel`
14#[repr(transparent)]
15#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
16pub struct LogLevel(pub Integer);
17
18impl LogLevel {
19    /// Undefined log level.
20    pub const UNDEFINED: Self = Self(0);
21    /// Debug log level.
22    pub const DEBUG: Self = Self(1);
23    /// Info log level.
24    pub const INFO: Self = Self(2);
25    /// Notice log level.
26    pub const NOTICE: Self = Self(3);
27    /// Error log level.
28    pub const ERROR: Self = Self(4);
29    /// Fault log level.
30    pub const FAULT: Self = Self(5);
31}
32
33// ============================================================================
34// LogStateError
35// ============================================================================
36
37/// Errors that can occur when creating a log state.
38///
39/// C++ equivalent: `MTL::LogStateError`
40#[repr(transparent)]
41#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
42pub struct LogStateError(pub UInteger);
43
44impl LogStateError {
45    /// Invalid buffer size error.
46    pub const INVALID_SIZE: Self = Self(1);
47    /// Invalid configuration error.
48    pub const INVALID: Self = Self(2);
49}
50
51// ============================================================================
52// FunctionLogType
53// ============================================================================
54
55/// Type of function log entry.
56///
57/// C++ equivalent: `MTL::FunctionLogType`
58#[repr(transparent)]
59#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
60pub struct FunctionLogType(pub UInteger);
61
62impl FunctionLogType {
63    /// Validation log entry.
64    pub const VALIDATION: Self = Self(0);
65}
66
67#[cfg(test)]
68mod tests {
69    use super::*;
70
71    #[test]
72    fn test_log_level_values() {
73        assert_eq!(LogLevel::UNDEFINED.0, 0);
74        assert_eq!(LogLevel::DEBUG.0, 1);
75        assert_eq!(LogLevel::INFO.0, 2);
76        assert_eq!(LogLevel::NOTICE.0, 3);
77        assert_eq!(LogLevel::ERROR.0, 4);
78        assert_eq!(LogLevel::FAULT.0, 5);
79    }
80
81    #[test]
82    fn test_log_state_error_values() {
83        assert_eq!(LogStateError::INVALID_SIZE.0, 1);
84        assert_eq!(LogStateError::INVALID.0, 2);
85    }
86
87    #[test]
88    fn test_function_log_type_values() {
89        assert_eq!(FunctionLogType::VALIDATION.0, 0);
90    }
91}