objc2_metal/generated/
MTLLogState.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// The level of the log entry.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlloglevel?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct MTLLogLevel(pub NSInteger);
17impl MTLLogLevel {
18    #[doc(alias = "MTLLogLevelUndefined")]
19    pub const Undefined: Self = Self(0);
20    #[doc(alias = "MTLLogLevelDebug")]
21    pub const Debug: Self = Self(1);
22    #[doc(alias = "MTLLogLevelInfo")]
23    pub const Info: Self = Self(2);
24    #[doc(alias = "MTLLogLevelNotice")]
25    pub const Notice: Self = Self(3);
26    #[doc(alias = "MTLLogLevelError")]
27    pub const Error: Self = Self(4);
28    #[doc(alias = "MTLLogLevelFault")]
29    pub const Fault: Self = Self(5);
30}
31
32unsafe impl Encode for MTLLogLevel {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for MTLLogLevel {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_protocol!(
41    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtllogstate?language=objc)
42    pub unsafe trait MTLLogState: NSObjectProtocol + Send + Sync {
43        #[cfg(feature = "block2")]
44        /// Add a function block to handle log message output.
45        /// In the absence of any handlers, log messages go through the default handler.
46        ///
47        /// # Safety
48        ///
49        /// `block` block must be sendable.
50        #[unsafe(method(addLogHandler:))]
51        #[unsafe(method_family = none)]
52        unsafe fn addLogHandler(
53            &self,
54            block: &block2::DynBlock<
55                dyn Fn(*mut NSString, *mut NSString, MTLLogLevel, NonNull<NSString>),
56            >,
57        );
58    }
59);
60
61extern_class!(
62    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtllogstatedescriptor?language=objc)
63    #[unsafe(super(NSObject))]
64    #[derive(Debug, PartialEq, Eq, Hash)]
65    pub struct MTLLogStateDescriptor;
66);
67
68extern_conformance!(
69    unsafe impl NSCopying for MTLLogStateDescriptor {}
70);
71
72unsafe impl CopyingHelper for MTLLogStateDescriptor {
73    type Result = Self;
74}
75
76extern_conformance!(
77    unsafe impl NSObjectProtocol for MTLLogStateDescriptor {}
78);
79
80impl MTLLogStateDescriptor {
81    extern_methods!(
82        /// level indicates the minimum level of the logs that will be printed.
83        ///
84        /// All the logs with level less than given level will be skipped on the GPU Side.
85        #[unsafe(method(level))]
86        #[unsafe(method_family = none)]
87        pub fn level(&self) -> MTLLogLevel;
88
89        /// Setter for [`level`][Self::level].
90        #[unsafe(method(setLevel:))]
91        #[unsafe(method_family = none)]
92        pub fn setLevel(&self, level: MTLLogLevel);
93
94        /// bufferSize indicates the size of the buffer where GPU will store the logging content from shaders. Minimum value is 1KB
95        #[unsafe(method(bufferSize))]
96        #[unsafe(method_family = none)]
97        pub fn bufferSize(&self) -> NSInteger;
98
99        /// Setter for [`bufferSize`][Self::bufferSize].
100        ///
101        /// # Safety
102        ///
103        /// This might not be bounds-checked.
104        #[unsafe(method(setBufferSize:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn setBufferSize(&self, buffer_size: NSInteger);
107    );
108}
109
110/// Methods declared on superclass `NSObject`.
111impl MTLLogStateDescriptor {
112    extern_methods!(
113        #[unsafe(method(init))]
114        #[unsafe(method_family = init)]
115        pub fn init(this: Allocated<Self>) -> Retained<Self>;
116
117        #[unsafe(method(new))]
118        #[unsafe(method_family = new)]
119        pub fn new() -> Retained<Self>;
120    );
121}
122
123impl DefaultRetained for MTLLogStateDescriptor {
124    #[inline]
125    fn default_retained() -> Retained<Self> {
126        Self::new()
127    }
128}
129
130extern "C" {
131    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtllogstateerrordomain?language=objc)
132    pub static MTLLogStateErrorDomain: &'static NSErrorDomain;
133}
134
135/// NSErrors raised when creating a logstate.
136///
137/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtllogstateerror?language=objc)
138// NS_ENUM
139#[repr(transparent)]
140#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
141pub struct MTLLogStateError(pub NSUInteger);
142impl MTLLogStateError {
143    #[doc(alias = "MTLLogStateErrorInvalidSize")]
144    pub const InvalidSize: Self = Self(1);
145    #[doc(alias = "MTLLogStateErrorInvalid")]
146    pub const Invalid: Self = Self(2);
147}
148
149unsafe impl Encode for MTLLogStateError {
150    const ENCODING: Encoding = NSUInteger::ENCODING;
151}
152
153unsafe impl RefEncode for MTLLogStateError {
154    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
155}