objc2-core-midi 0.3.2

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

use crate::*;

#[cfg(feature = "objc2")]
extern_class!(
    /// A mutable MIDIUMPEndpoint object.
    ///
    ///
    /// It is not necessary to create a MIDIUMPEndpoint or other MIDI endpoint in order to
    /// use UMP natively. Any standard MIDI endpoint created with a specified MIDIProtocolID
    /// is assumed to use all 16 UMP groups for the same unspecified function and to neither
    /// transmit nor receive jitter-reduction timestamps.
    ///
    /// This API is not realtime-safe, all interaction with the mutable endpoint should be done on the
    /// main thread.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiumpmutableendpoint?language=objc)
    #[unsafe(super(MIDIUMPEndpoint, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "MIDIUMPEndpoint", feature = "objc2"))]
    pub struct MIDIUMPMutableEndpoint;
);

#[cfg(all(feature = "MIDIUMPEndpoint", feature = "objc2"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for MIDIUMPMutableEndpoint {}
);

#[cfg(all(feature = "MIDIUMPEndpoint", feature = "objc2"))]
impl MIDIUMPMutableEndpoint {
    extern_methods!(
        #[cfg(all(
            feature = "MIDIUMPFunctionBlock",
            feature = "MIDIUMPMutableFunctionBlock",
            feature = "objc2-foundation"
        ))]
        /// The Function Blocks associated with the UMP endpoint, if any.
        #[unsafe(method(mutableFunctionBlocks))]
        #[unsafe(method_family = none)]
        pub unsafe fn mutableFunctionBlocks(
            &self,
        ) -> Retained<NSArray<MIDIUMPMutableFunctionBlock>>;

        #[cfg(all(
            feature = "MIDIUMPFunctionBlock",
            feature = "MIDIUMPMutableFunctionBlock",
            feature = "objc2-foundation"
        ))]
        /// Setter for [`mutableFunctionBlocks`][Self::mutableFunctionBlocks].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setMutableFunctionBlocks:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMutableFunctionBlocks(
            &self,
            mutable_function_blocks: &NSArray<MIDIUMPMutableFunctionBlock>,
        );

        /// The enable state of the endpoint.
        #[unsafe(method(isEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn isEnabled(&self) -> bool;

        #[cfg(all(
            feature = "MIDIServices",
            feature = "block2",
            feature = "objc2-foundation"
        ))]
        /// Initializer for creating a new MIDIUMPEndpoint.
        ///
        ///
        /// Parameter `name`: The UMP endpoint name.
        ///
        /// Parameter `deviceInfo`: The MIDI 2 device ID info for the UMP endpoint.
        ///
        /// Parameter `productInstanceID`: The product instance ID, up to 42 characters.
        ///
        /// Parameter `MIDIProtocol`: The MIDI protocol.
        ///
        /// Parameter `destinationCallback`: The receive callback used to create the UMP endpoint's MIDI
        /// destination associated, which can be used to observe or process
        /// incoming MIDI traffic.
        ///
        ///
        /// This operation will fail if the device ID information is malformed or if virtual MIDI endpoint creation
        /// is not allowed (for example, on iOS, if your app doesn't list 'audio' in UIBackgroundModes).
        ///
        /// # Safety
        ///
        /// `destination_callback` must be a valid pointer.
        #[unsafe(method(initWithName:deviceInfo:productInstanceID:MIDIProtocol:destinationCallback:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithName_deviceInfo_productInstanceID_MIDIProtocol_destinationCallback(
            this: Allocated<Self>,
            name: &NSString,
            device_info: &MIDI2DeviceInfo,
            product_instance_id: &NSString,
            midi_protocol: MIDIProtocolID,
            destination_callback: MIDIReceiveBlock,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "objc2-foundation")]
        /// Set the endpoints name.
        ///
        ///
        /// Parameter `name`: A string representing the name of the endpoint.
        ///
        /// Parameter `error`: The out-error used if an error occurs.
        ///
        ///
        /// Returns: YES for success. NO in the event of a failure, in which case the error is returned in error.
        ///
        ///
        /// This operation will fail if the name could not be set.
        #[unsafe(method(setName:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn setName_error(&self, name: &NSString) -> Result<(), Retained<NSError>>;

        #[cfg(all(
            feature = "MIDIUMPFunctionBlock",
            feature = "MIDIUMPMutableFunctionBlock",
            feature = "objc2-foundation"
        ))]
        /// Register or replace Function Blocks for a disabled client-created MIDIUMPEndpoint.
        ///
        ///
        /// Parameter `functionBlocks`: A list of client-created Function Blocks to register.
        ///
        /// Parameter `markAsStatic`: Whether the Function Block configuration may be updated.
        ///
        /// Parameter `error`: The out-error used if an error occurs.
        ///
        ///
        /// Returns: YES for success. NO in the event of a failure, in which case the error is returned in error.
        ///
        ///
        /// This operation will fail if the array contains any disabled Function Blocks but the
        /// MIDIUMPEndpoint Function Block configuration is static.
        /// Returns YES if the Function Block configuration was set successfully.
        #[unsafe(method(registerFunctionBlocks:markAsStatic:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn registerFunctionBlocks_markAsStatic_error(
            &self,
            function_blocks: &NSArray<MIDIUMPMutableFunctionBlock>,
            mark_as_static: bool,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "objc2-foundation")]
        /// Enable a mutable UMP endpoint in the system-wide UMP endpoint cache.
        ///
        ///
        /// Parameter `isEnabled`: The enable state of the UMP endpoint.
        ///
        /// Parameter `error`: The out-error used if an error occurred.
        ///
        ///
        /// Returns: YES for success. NO in the event of a failure, in which case the error is returned in error.
        ///
        ///
        /// A MIDIUMPMutableEndpoint must be cache enabled before it is visible via API.
        /// Note that Function Blocks may only be registered to uncached MIDIUMPMutableEndpoint
        /// objects.
        #[unsafe(method(setEnabled:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn setEnabled_error(&self, is_enabled: bool) -> Result<(), Retained<NSError>>;
    );
}

/// Methods declared on superclass `MIDIUMPEndpoint`.
#[cfg(all(feature = "MIDIUMPEndpoint", feature = "objc2"))]
impl MIDIUMPMutableEndpoint {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "MIDIUMPEndpoint", feature = "objc2"))]
impl MIDIUMPMutableEndpoint {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}