objc2_sound_analysis/generated/SNTimeDurationConstraint.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::*;
5#[cfg(feature = "objc2-core-media")]
6use objc2_core_media::*;
7use objc2_foundation::*;
8
9use crate::*;
10
11/// Enumerates possible types for `SNTimeDurationConstraint`.
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/soundanalysis/sntimedurationconstrainttype?language=objc)
14// NS_ENUM
15#[repr(transparent)]
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
17pub struct SNTimeDurationConstraintType(pub NSInteger);
18impl SNTimeDurationConstraintType {
19 /// An 'enumerated' constraint type.
20 ///
21 /// In order for a duration to satisfy a constraint of this type, it must be a member of a particular set of discrete permissible values.
22 #[doc(alias = "SNTimeDurationConstraintTypeEnumerated")]
23 pub const Enumerated: Self = Self(1);
24 /// A 'range' constraint type.
25 ///
26 /// In order for a duration to satisfy a constraint of this type, it must be a member of a particular continuous range of permissible values.
27 #[doc(alias = "SNTimeDurationConstraintTypeRange")]
28 pub const Range: Self = Self(2);
29}
30
31unsafe impl Encode for SNTimeDurationConstraintType {
32 const ENCODING: Encoding = NSInteger::ENCODING;
33}
34
35unsafe impl RefEncode for SNTimeDurationConstraintType {
36 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39extern_class!(
40 /// Constrains CMTime durations to a subset of legal values.
41 ///
42 /// `SNTimeDurationConstraint` is a union type, which, based on the value of its `type` property, may assume one of several forms. Instance properties may be used to extract information from an object, but certain properties are only valid to exercise under certain circumstances. Before accessing a particular property, refer to its documentation to understand what `type` value is required in order for that property to be valid.
43 ///
44 /// See also [Apple's documentation](https://developer.apple.com/documentation/soundanalysis/sntimedurationconstraint?language=objc)
45 #[unsafe(super(NSObject))]
46 #[derive(Debug, PartialEq, Eq, Hash)]
47 pub struct SNTimeDurationConstraint;
48);
49
50extern_conformance!(
51 unsafe impl NSObjectProtocol for SNTimeDurationConstraint {}
52);
53
54impl SNTimeDurationConstraint {
55 extern_methods!(
56 /// The time constraint type.
57 ///
58 /// The value of this property dictates whether or not other properties associated with this class can be validly accessed. Please refer to the documentation of other individual properties to understand their relationship to this one. This property is always valid to access.
59 #[unsafe(method(type))]
60 #[unsafe(method_family = none)]
61 pub unsafe fn r#type(&self) -> SNTimeDurationConstraintType;
62
63 /// If the constraint type is enumerated, then the set of discrete allowable time durations.
64 ///
65 /// - Returns: If the constraint type is enumerated, an array of CMTime structures (boxed in NSValue instances) representing the set of allowable time durations. The durations will always be provided sorted in order of ascending time. If the constraint type is not enumerated, an empty array will be returned.
66 ///
67 /// The `type` property should be queried before this property is accessed. This property will only yield meaningful values if the constraint type is considered to be 'enumerated'. The constraint type is considered to be 'enumerated' if the `type` property is equal to `SNTimeDurationConstraintTypeEnumerated`.
68 #[unsafe(method(enumeratedDurations))]
69 #[unsafe(method_family = none)]
70 pub unsafe fn enumeratedDurations(&self) -> Retained<NSArray<NSValue>>;
71
72 #[cfg(feature = "objc2-core-media")]
73 /// If the constraint type is range, then the range of allowable window durations.
74 ///
75 /// - Returns: If the constraint type is range, a CMTimeRange representing the range of allowable window durations. If the constraint type is not range, `kCMTimeRangeInvalid`.
76 ///
77 /// The `type` property should be queried before this property is accessed. This property will only yield meaningful values if the constraint type is considered to be 'range'. The constraint type is considered to be 'range' if the `type` property is equal to `SNTimeDurationConstraintTypeRange`.
78 #[unsafe(method(durationRange))]
79 #[unsafe(method_family = none)]
80 pub unsafe fn durationRange(&self) -> CMTimeRange;
81
82 /// Initializes an enumerated-type constraint.
83 ///
84 /// - Parameter enumeratedDurations: A discrete set of duration values (represented as CMTime values boxed in NSValue instances) permitted by this constraint.
85 ///
86 /// - Returns: An instance whose `type` is `SNTimeDurationConstraintTypeEnumerated`, and which constrains duration values to the provided set of discrete values.
87 #[unsafe(method(initWithEnumeratedDurations:))]
88 #[unsafe(method_family = init)]
89 pub unsafe fn initWithEnumeratedDurations(
90 this: Allocated<Self>,
91 enumerated_durations: &NSArray<NSValue>,
92 ) -> Retained<Self>;
93
94 #[cfg(feature = "objc2-core-media")]
95 /// Initializes a range-type constraint.
96 ///
97 /// - Parameter durationRange: A continuous range of duration values (represented as CMTime values) permitted by this constraint.
98 ///
99 /// - Returns: An instance whose `type` is `SNTimeDurationConstraintTypeRange`, and which constrains durations values to the provided range.
100 #[unsafe(method(initWithDurationRange:))]
101 #[unsafe(method_family = init)]
102 pub unsafe fn initWithDurationRange(
103 this: Allocated<Self>,
104 duration_range: CMTimeRange,
105 ) -> Retained<Self>;
106
107 #[unsafe(method(init))]
108 #[unsafe(method_family = init)]
109 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
110
111 #[unsafe(method(new))]
112 #[unsafe(method_family = new)]
113 pub unsafe fn new() -> Retained<Self>;
114 );
115}