objc2-app-kit 0.3.2

Bindings to the AppKit 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::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsspeechrecognizer?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSSpeechRecognizer;
);

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

impl NSSpeechRecognizer {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Option<Retained<Self>>;

        #[unsafe(method(startListening))]
        #[unsafe(method_family = none)]
        pub fn startListening(&self);

        #[unsafe(method(stopListening))]
        #[unsafe(method_family = none)]
        pub fn stopListening(&self);

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub fn delegate(
            &self,
            mtm: MainThreadMarker,
        ) -> Option<Retained<ProtocolObject<dyn NSSpeechRecognizerDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn NSSpeechRecognizerDelegate>>,
        );

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

        /// Setter for [`commands`][Self::commands].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setCommands:))]
        #[unsafe(method_family = none)]
        pub fn setCommands(&self, commands: Option<&NSArray<NSString>>);

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

        /// Setter for [`displayedCommandsTitle`][Self::displayedCommandsTitle].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setDisplayedCommandsTitle:))]
        #[unsafe(method_family = none)]
        pub fn setDisplayedCommandsTitle(&self, displayed_commands_title: Option<&NSString>);

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

        /// Setter for [`listensInForegroundOnly`][Self::listensInForegroundOnly].
        #[unsafe(method(setListensInForegroundOnly:))]
        #[unsafe(method_family = none)]
        pub fn setListensInForegroundOnly(&self, listens_in_foreground_only: bool);

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

        /// Setter for [`blocksOtherRecognizers`][Self::blocksOtherRecognizers].
        #[unsafe(method(setBlocksOtherRecognizers:))]
        #[unsafe(method_family = none)]
        pub fn setBlocksOtherRecognizers(&self, blocks_other_recognizers: bool);
    );
}

/// Methods declared on superclass `NSObject`.
impl NSSpeechRecognizer {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for NSSpeechRecognizer {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsspeechrecognizerdelegate?language=objc)
    pub unsafe trait NSSpeechRecognizerDelegate: NSObjectProtocol + MainThreadOnly {
        #[optional]
        #[unsafe(method(speechRecognizer:didRecognizeCommand:))]
        #[unsafe(method_family = none)]
        fn speechRecognizer_didRecognizeCommand(
            &self,
            sender: &NSSpeechRecognizer,
            command: &NSString,
        );
    }
);