objc2_core_haptics/generated/
CHHapticPattern.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// Keys used to define a CHHapticPattern.
10///
11///
12/// A definition for a haptic pattern consists of a heirarchical set of key/value pairs, starting at the topmost level with
13/// a "Version" and a "Pattern" key.  The "Pattern" marks the beginning of an array of event (CHHapticPatternKeyEvent)
14/// and parameter (CHHapticPatternKeyParameter) definitions.  Each of these has an associated time which indicates when the event or parameter
15/// will be delivered to the haptic engine.
16///
17///
18/// The version of the system for which the pattern was authored.
19/// Value type: Real.
20///
21///
22/// Indicates the beginning of a haptic pattern definition.
23/// Value type: Array.
24///
25///
26/// Indicates the beginning of a haptic event definition, which will include an event type, a time, and an optional set
27/// of event parameters (CHHapticPatternKeyEventParameters).
28/// Value type: Dictionary.
29///
30///
31/// The type of haptic or audio event.
32/// Value type: NSString (CHHapticEventType).
33///
34///
35/// The duration in seconds for an event.
36/// Value type: Real.
37///
38///
39/// Indicates the beginning of an array of event parameter (CHHapticPatternKeyParameter) definitions for a specific event.
40/// Value type: Array.
41///
42///
43/// Indicates the beginning of a parameter definition, which will include a parameter type and value, and a time.
44/// Value type: Dictionary.
45///
46///
47/// The ID of the parameter.
48/// Value type: NSString (CHHapticEventParameterID for event parameters and CHHapticDynamicParameterID for dynamic parameters).
49///
50///
51/// The value of the parameter.  The range will vary with the parameter.
52/// Value type: Real.
53///
54///
55/// The relative time for any event or parameter.  Units are seconds.
56/// Value type: Real.
57///
58///
59/// For events of type CHHapticEventTypeAudioCustom, the path to the local file containing the audio waveform.
60/// Value type: NSString.
61///
62///
63/// For events of type CHHapticEventTypeAudioCustom, indicates whether the audio file playback should be ramped in and out with an envelope.
64/// This can be useful for preventing clicks during playback, or for cases where the application wants to modulate this envelope to use different
65/// attack and release times.
66/// Value type: boolean.  Default is true.
67///
68///
69/// For events of type CHHapticEventTypeAudioCustom, indicates whether the audio file playback will be looped.
70/// Value type: boolean.  Default is false.
71///
72/// See also [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkey?language=objc)
73// NS_TYPED_ENUM
74pub type CHHapticPatternKey = NSString;
75
76extern "C" {
77    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyversion?language=objc)
78    pub static CHHapticPatternKeyVersion: &'static CHHapticPatternKey;
79}
80
81extern "C" {
82    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeypattern?language=objc)
83    pub static CHHapticPatternKeyPattern: &'static CHHapticPatternKey;
84}
85
86extern "C" {
87    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyevent?language=objc)
88    pub static CHHapticPatternKeyEvent: &'static CHHapticPatternKey;
89}
90
91extern "C" {
92    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventtype?language=objc)
93    pub static CHHapticPatternKeyEventType: &'static CHHapticPatternKey;
94}
95
96extern "C" {
97    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeytime?language=objc)
98    pub static CHHapticPatternKeyTime: &'static CHHapticPatternKey;
99}
100
101extern "C" {
102    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventduration?language=objc)
103    pub static CHHapticPatternKeyEventDuration: &'static CHHapticPatternKey;
104}
105
106extern "C" {
107    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventwaveformpath?language=objc)
108    pub static CHHapticPatternKeyEventWaveformPath: &'static CHHapticPatternKey;
109}
110
111extern "C" {
112    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventparameters?language=objc)
113    pub static CHHapticPatternKeyEventParameters: &'static CHHapticPatternKey;
114}
115
116extern "C" {
117    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventwaveformusevolumeenvelope?language=objc)
118    pub static CHHapticPatternKeyEventWaveformUseVolumeEnvelope: &'static CHHapticPatternKey;
119}
120
121extern "C" {
122    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventwaveformloopenabled?language=objc)
123    pub static CHHapticPatternKeyEventWaveformLoopEnabled: &'static CHHapticPatternKey;
124}
125
126extern "C" {
127    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyparameter?language=objc)
128    pub static CHHapticPatternKeyParameter: &'static CHHapticPatternKey;
129}
130
131extern "C" {
132    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyparameterid?language=objc)
133    pub static CHHapticPatternKeyParameterID: &'static CHHapticPatternKey;
134}
135
136extern "C" {
137    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyparametervalue?language=objc)
138    pub static CHHapticPatternKeyParameterValue: &'static CHHapticPatternKey;
139}
140
141extern "C" {
142    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyparametercurve?language=objc)
143    pub static CHHapticPatternKeyParameterCurve: &'static CHHapticPatternKey;
144}
145
146extern "C" {
147    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyparametercurvecontrolpoints?language=objc)
148    pub static CHHapticPatternKeyParameterCurveControlPoints: &'static CHHapticPatternKey;
149}
150
151extern_class!(
152    /// A set of one or more haptic events and/or Dynamic parameters/parameter curves.
153    ///
154    /// The passed-in arrays' contents are not owned by the pattern object.  Changes made to those arrays
155    /// after a CHHapticPattern object is created have no effect on that object.
156    ///
157    /// See also [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpattern?language=objc)
158    #[unsafe(super(NSObject))]
159    #[derive(Debug, PartialEq, Eq, Hash)]
160    pub struct CHHapticPattern;
161);
162
163extern_conformance!(
164    unsafe impl NSObjectProtocol for CHHapticPattern {}
165);
166
167impl CHHapticPattern {
168    extern_methods!(
169        /// Pattern duration is calculated as the start time of the pattern's last event or parameter, plus that event's duration if present.
170        #[unsafe(method(duration))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn duration(&self) -> NSTimeInterval;
173
174        #[unsafe(method(init))]
175        #[unsafe(method_family = init)]
176        pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
177
178        #[cfg(all(feature = "CHHapticEvent", feature = "CHHapticParameter"))]
179        /// Initialize a new CHHapticPattern.
180        ///
181        /// Parameter `events`: An NSArray of CHHapticEvents.  Can be empty.
182        ///
183        /// Parameter `parameters`: An NSArray of CHHapticDynamicParameters.  Can be empty.
184        #[unsafe(method(initWithEvents:parameters:error:_))]
185        #[unsafe(method_family = init)]
186        pub unsafe fn initWithEvents_parameters_error(
187            this: Allocated<Self>,
188            events: &NSArray<CHHapticEvent>,
189            parameters: &NSArray<CHHapticDynamicParameter>,
190        ) -> Result<Retained<Self>, Retained<NSError>>;
191
192        #[cfg(all(feature = "CHHapticEvent", feature = "CHHapticParameter"))]
193        /// Initialize a new CHHapticPattern with parameters modulated by parameter curves.
194        ///
195        /// Parameter `events`: An NSArray of CHHapticEvents.  Can be empty.
196        ///
197        /// Parameter `parameterCurves`: An NSArray of CHHapticParameterCurves.  Can be empty.
198        #[unsafe(method(initWithEvents:parameterCurves:error:_))]
199        #[unsafe(method_family = init)]
200        pub unsafe fn initWithEvents_parameterCurves_error(
201            this: Allocated<Self>,
202            events: &NSArray<CHHapticEvent>,
203            parameter_curves: &NSArray<CHHapticParameterCurve>,
204        ) -> Result<Retained<Self>, Retained<NSError>>;
205
206        /// Initialize a new CHHapticPattern using the passed-in NSDictionary.
207        ///
208        /// Parameter `patternDict`: NSDictionary containing a pattern property list.
209        ///
210        /// # Safety
211        ///
212        /// `pattern_dict` generic should be of the correct type.
213        #[unsafe(method(initWithDictionary:error:_))]
214        #[unsafe(method_family = init)]
215        pub unsafe fn initWithDictionary_error(
216            this: Allocated<Self>,
217            pattern_dict: &NSDictionary<CHHapticPatternKey, AnyObject>,
218        ) -> Result<Retained<Self>, Retained<NSError>>;
219
220        /// Initialize a new CHHapticPattern using the contents of the passed-in NSURL.
221        ///
222        /// Parameter `ahapURL`: NSURL of an ahap file.
223        ///
224        /// This URL must reference a valid AHAP file.
225        #[unsafe(method(initWithContentsOfURL:error:_))]
226        #[unsafe(method_family = init)]
227        pub unsafe fn initWithContentsOfURL_error(
228            this: Allocated<Self>,
229            ahap_url: &NSURL,
230        ) -> Result<Retained<Self>, Retained<NSError>>;
231
232        /// Returns a NSDictionary representation of the contents of the pattern.
233        ///
234        /// Patterns containing custom audio resource IDs cannot be exported and will return nil
235        /// with the error code set to CHHapticErrorCodeOperationNotPermitted.
236        #[unsafe(method(exportDictionaryAndReturnError:_))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn exportDictionaryAndReturnError(
239            &self,
240        ) -> Result<Retained<NSDictionary<CHHapticPatternKey, AnyObject>>, Retained<NSError>>;
241    );
242}
243
244/// Methods declared on superclass `NSObject`.
245impl CHHapticPattern {
246    extern_methods!(
247        #[unsafe(method(new))]
248        #[unsafe(method_family = new)]
249        pub unsafe fn new() -> Retained<Self>;
250    );
251}