objc2-car-play 0.3.2

Bindings to the CarPlay framework
Documentation
//! 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::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;

use crate::*;

extern_class!(
    /// `CPVoiceControlState`encapsulates the title variants and image(s) for a single voice control
    /// state, like listening, loading, or recognized.
    ///
    /// Your app may initialize the voice control template with one or more states, and
    /// you may call
    /// `activateVoiceControlState:`to switch between states you've defined.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpvoicecontrolstate?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CPVoiceControlState;
);

extern_conformance!(
    unsafe impl NSCoding for CPVoiceControlState {}
);

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

extern_conformance!(
    unsafe impl NSSecureCoding for CPVoiceControlState {}
);

impl CPVoiceControlState {
    extern_methods!(
        #[cfg(feature = "objc2-ui-kit")]
        /// Initialize a voice control state with a title and image.
        ///
        ///
        /// Parameter `identifier`: A custom identifier you can use to identify this voice control state. You'll also
        /// switch to this state by specifying this identifier.
        ///
        /// Parameter `titleVariants`: An array of title variants. The Voice Control template will select the longest
        /// variant that fits your specified content.
        ///
        /// Parameter `image`: An image to be animated while this template is visible. The system
        /// enforces a minimum cycle duration of 0.3 seconds and a maximum cycle duration of 5 seconds.
        /// Voice Control state images may be a maximum of 150 by 150 points.
        ///
        /// Parameter `repeats`: For an animated image, YES if the animation should repeat indefinitely, NO
        /// to run the animation only once.
        #[unsafe(method(initWithIdentifier:titleVariants:image:repeats:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithIdentifier_titleVariants_image_repeats(
            this: Allocated<Self>,
            identifier: &NSString,
            title_variants: Option<&NSArray<NSString>>,
            image: Option<&UIImage>,
            repeats: bool,
        ) -> Retained<Self>;

        #[unsafe(method(titleVariants))]
        #[unsafe(method_family = none)]
        pub unsafe fn titleVariants(&self) -> Option<Retained<NSArray<NSString>>>;

        #[cfg(feature = "objc2-ui-kit")]
        #[unsafe(method(image))]
        #[unsafe(method_family = none)]
        pub unsafe fn image(&self) -> Option<Retained<UIImage>>;

        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn identifier(&self) -> Retained<NSString>;

        #[unsafe(method(repeats))]
        #[unsafe(method_family = none)]
        pub unsafe fn repeats(&self) -> bool;
    );
}

/// Methods declared on superclass `NSObject`.
impl CPVoiceControlState {
    extern_methods!(
        #[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>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpvoicecontroltemplate?language=objc)
    #[unsafe(super(CPTemplate, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CPTemplate")]
    pub struct CPVoiceControlTemplate;
);

#[cfg(feature = "CPTemplate")]
extern_conformance!(
    unsafe impl NSCoding for CPVoiceControlTemplate {}
);

#[cfg(feature = "CPTemplate")]
extern_conformance!(
    unsafe impl NSObjectProtocol for CPVoiceControlTemplate {}
);

#[cfg(feature = "CPTemplate")]
extern_conformance!(
    unsafe impl NSSecureCoding for CPVoiceControlTemplate {}
);

#[cfg(feature = "CPTemplate")]
impl CPVoiceControlTemplate {
    extern_methods!(
        /// Initialize a voice control template with a list of voice control states.
        ///
        ///
        /// Parameter `voiceControlStates`: An array of voice control states for this template. Your app can switch between these states after the template is presented.
        ///
        ///
        /// Note: By default, the Voice Control template will begin on the first state specified.
        ///
        ///
        /// Warning: You may specify a maximum of 5 voice control states. If you specify more than 5, only the first 5 will be available.
        #[unsafe(method(initWithVoiceControlStates:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithVoiceControlStates(
            this: Allocated<Self>,
            voice_control_states: &NSArray<CPVoiceControlState>,
        ) -> Retained<Self>;

        #[unsafe(method(voiceControlStates))]
        #[unsafe(method_family = none)]
        pub unsafe fn voiceControlStates(&self) -> Retained<NSArray<CPVoiceControlState>>;

        /// Switch the voice control template to the state corresponding with a particular identifier.
        ///
        ///
        /// Parameter `identifier`: An identifier corresponding to one of the voice control states used to initialize this template.
        ///
        ///
        /// Note: The Voice Control template applies a rate-limit for voice control states; the template will
        /// ignore voice control state changes that occur too rapidly or frequently in a short period of time.
        ///
        ///
        /// Warning: You must first present this voice control template through your
        /// `CPInterfaceController`before
        /// activating a voice control state, otherwise this method will have no effect.
        /// When the Voice Control template is first presented, the first state you specify in
        /// `initWithVoiceControlStates:`will be visible.
        #[unsafe(method(activateVoiceControlStateWithIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn activateVoiceControlStateWithIdentifier(&self, identifier: &NSString);

        /// The currently-active voice control state identifier.
        #[unsafe(method(activeStateIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn activeStateIdentifier(&self) -> Option<Retained<NSString>>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "CPTemplate")]
impl CPVoiceControlTemplate {
    extern_methods!(
        #[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(mtm: MainThreadMarker) -> Retained<Self>;
    );
}