objc2-sound-analysis 0.3.2

Bindings to the SoundAnalysis framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
use objc2_foundation::*;

use crate::*;

/// Enumerates possible types for `SNTimeDurationConstraint`.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/soundanalysis/sntimedurationconstrainttype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SNTimeDurationConstraintType(pub NSInteger);
impl SNTimeDurationConstraintType {
    /// An 'enumerated' constraint type.
    ///
    /// 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.
    #[doc(alias = "SNTimeDurationConstraintTypeEnumerated")]
    pub const Enumerated: Self = Self(1);
    /// A 'range' constraint type.
    ///
    /// 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.
    #[doc(alias = "SNTimeDurationConstraintTypeRange")]
    pub const Range: Self = Self(2);
}

unsafe impl Encode for SNTimeDurationConstraintType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for SNTimeDurationConstraintType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// Constrains CMTime durations to a subset of legal values.
    ///
    /// `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.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/soundanalysis/sntimedurationconstraint?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SNTimeDurationConstraint;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for SNTimeDurationConstraint {}
);

impl SNTimeDurationConstraint {
    extern_methods!(
        /// The time constraint type.
        ///
        /// 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.
        #[unsafe(method(type))]
        #[unsafe(method_family = none)]
        pub unsafe fn r#type(&self) -> SNTimeDurationConstraintType;

        /// If the constraint type is enumerated, then the set of discrete allowable time durations.
        ///
        /// - 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.
        ///
        /// 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`.
        #[unsafe(method(enumeratedDurations))]
        #[unsafe(method_family = none)]
        pub unsafe fn enumeratedDurations(&self) -> Retained<NSArray<NSValue>>;

        #[cfg(feature = "objc2-core-media")]
        /// If the constraint type is range, then the range of allowable window durations.
        ///
        /// - Returns: If the constraint type is range, a CMTimeRange representing the range of allowable window durations. If the constraint type is not range, `kCMTimeRangeInvalid`.
        ///
        /// 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`.
        #[unsafe(method(durationRange))]
        #[unsafe(method_family = none)]
        pub unsafe fn durationRange(&self) -> CMTimeRange;

        /// Initializes an enumerated-type constraint.
        ///
        /// - Parameter enumeratedDurations: A discrete set of duration values (represented as CMTime values boxed in NSValue instances) permitted by this constraint.
        ///
        /// - Returns: An instance whose `type` is `SNTimeDurationConstraintTypeEnumerated`, and which constrains duration values to the provided set of discrete values.
        #[unsafe(method(initWithEnumeratedDurations:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithEnumeratedDurations(
            this: Allocated<Self>,
            enumerated_durations: &NSArray<NSValue>,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-media")]
        /// Initializes a range-type constraint.
        ///
        /// - Parameter durationRange: A continuous range of duration values (represented as CMTime values) permitted by this constraint.
        ///
        /// - Returns: An instance whose `type` is `SNTimeDurationConstraintTypeRange`, and which constrains durations values to the provided range.
        #[unsafe(method(initWithDurationRange:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDurationRange(
            this: Allocated<Self>,
            duration_range: CMTimeRange,
        ) -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}