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