objc2_metal/generated/
MTL4PipelineDataSetSerializer.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/// Configuration options for pipeline dataset serializer objects.
11///
12/// Use these options to enable different functionality in instances of ``MTL4PipelineDataSetSerializer``.
13///
14/// You can combine these values via a logical `OR` and set it to ``MTL4PipelineDataSetSerializerDescriptor/configuration``
15/// to specify desired level of serialization support for instances of ``MTL4PipelineDataSetSerializer``.
16///
17/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4pipelinedatasetserializerconfiguration?language=objc)
18// NS_OPTIONS
19#[repr(transparent)]
20#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
21pub struct MTL4PipelineDataSetSerializerConfiguration(pub NSUInteger);
22bitflags::bitflags! {
23    impl MTL4PipelineDataSetSerializerConfiguration: NSUInteger {
24/// Enables serializing pipeline scripts.
25///
26/// Set this mask to use ``MTL4PipelineDataSetSerializer.serializeAsPipelinesScriptWithError``.
27///
28/// This for the default behavior.
29        #[doc(alias = "MTL4PipelineDataSetSerializerConfigurationCaptureDescriptors")]
30        const CaptureDescriptors = 1<<0;
31/// Enables serializing pipeline binary functions.
32///
33/// Set this mask to use ``MTL4PipelineDataSetSerializer.serializeAsArchiveAndFlush(toURL:error:)``.
34        #[doc(alias = "MTL4PipelineDataSetSerializerConfigurationCaptureBinaries")]
35        const CaptureBinaries = 1<<1;
36    }
37}
38
39unsafe impl Encode for MTL4PipelineDataSetSerializerConfiguration {
40    const ENCODING: Encoding = NSUInteger::ENCODING;
41}
42
43unsafe impl RefEncode for MTL4PipelineDataSetSerializerConfiguration {
44    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
45}
46
47extern_class!(
48    /// Groups together properties to create a pipeline data set serializer.
49    ///
50    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4pipelinedatasetserializerdescriptor?language=objc)
51    #[unsafe(super(NSObject))]
52    #[derive(Debug, PartialEq, Eq, Hash)]
53    pub struct MTL4PipelineDataSetSerializerDescriptor;
54);
55
56extern_conformance!(
57    unsafe impl NSCopying for MTL4PipelineDataSetSerializerDescriptor {}
58);
59
60unsafe impl CopyingHelper for MTL4PipelineDataSetSerializerDescriptor {
61    type Result = Self;
62}
63
64extern_conformance!(
65    unsafe impl NSObjectProtocol for MTL4PipelineDataSetSerializerDescriptor {}
66);
67
68impl MTL4PipelineDataSetSerializerDescriptor {
69    extern_methods!(
70        /// Specifies the configuration of the serialization process.
71        ///
72        /// The configuration of the serialization process determines the mechanisms you use to serialize pipeline data sets.
73        ///
74        /// When this configuration contains ``MTL4PipelineDataSetSerializerConfigurationCaptureDescriptors``, use
75        /// ``serializeAsPipelinesScriptWithError:`` to serialize pipeline scripts.
76        ///
77        /// If this option contains ``MTL4PipelineDataSetSerializerConfigurationCaptureBinaries``, the serializer can additionally
78        /// serialize to a binary archive by calling ``serializeAsArchiveAndFlushToURL:error::``.
79        #[unsafe(method(configuration))]
80        #[unsafe(method_family = none)]
81        pub fn configuration(&self) -> MTL4PipelineDataSetSerializerConfiguration;
82
83        /// Setter for [`configuration`][Self::configuration].
84        #[unsafe(method(setConfiguration:))]
85        #[unsafe(method_family = none)]
86        pub fn setConfiguration(&self, configuration: MTL4PipelineDataSetSerializerConfiguration);
87    );
88}
89
90/// Methods declared on superclass `NSObject`.
91impl MTL4PipelineDataSetSerializerDescriptor {
92    extern_methods!(
93        #[unsafe(method(init))]
94        #[unsafe(method_family = init)]
95        pub fn init(this: Allocated<Self>) -> Retained<Self>;
96
97        #[unsafe(method(new))]
98        #[unsafe(method_family = new)]
99        pub fn new() -> Retained<Self>;
100    );
101}
102
103impl DefaultRetained for MTL4PipelineDataSetSerializerDescriptor {
104    #[inline]
105    fn default_retained() -> Retained<Self> {
106        Self::new()
107    }
108}
109
110extern_protocol!(
111    /// A fast-addition container for collecting data during pipeline state creation.
112    ///
113    /// Pipeline data serializer instances allow you to create binary archives and serialize pipeline scripts to use with
114    /// the offline Metal binary generator (`metal-tt`)
115    /// <doc
116    /// :compiling-binary-archives-from-a-custom-configuration-script.md>.
117    ///
118    /// You capture and retain all relevant data for all pipelines a compiler instance creates by providing an instance of
119    /// this object to its ``MTL4CompilerDescriptor``.
120    ///
121    /// After capturing data, you can serialize it to a binary archive to persist its contents offline by calling
122    /// ``serializeAsArchiveAndFlushToURL:error:``. You can also serialize a pipeline script suitable for the offline binary
123    /// generator (`metal-tt`) by calling ``serializeAsPipelinesScriptWithError:``
124    ///
125    /// - Note: The objects ``MTL4PipelineDataSetSerializer`` contains are opaque and can't accelerate compilation for
126    /// compilers they are not attached to. Additionally, your program can't read data out of data set serializer instances.
127    ///
128    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4pipelinedatasetserializer?language=objc)
129    pub unsafe trait MTL4PipelineDataSetSerializer: NSObjectProtocol {
130        /// Serializes a pipeline data set to an archive.
131        ///
132        /// - Parameters:
133        /// - url: the URL used to serialize the serializer data set as an archive to.
134        /// - error: an optional parameter to store information in case of an error.
135        /// - Returns: a boolean indicating whether the operation was successful.
136        #[unsafe(method(serializeAsArchiveAndFlushToURL:error:_))]
137        #[unsafe(method_family = none)]
138        fn serializeAsArchiveAndFlushToURL_error(
139            &self,
140            url: &NSURL,
141        ) -> Result<(), Retained<NSError>>;
142
143        /// Serializes a serializer data set to a pipeline script as raw data.
144        ///
145        /// - Parameters:
146        /// - error: an optional parameter to store information in case of an error.
147        /// - Returns: an `NSData` instance containing the pipeline script.
148        #[unsafe(method(serializeAsPipelinesScriptWithError:_))]
149        #[unsafe(method_family = none)]
150        fn serializeAsPipelinesScriptWithError(
151            &self,
152        ) -> Result<Retained<NSData>, Retained<NSError>>;
153    }
154);