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!(
    /// An NSObject containing basic information about a MIDI 2.0 device. Used by
    /// MIDIUMPEndpointPair and MIDICIDevice.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midi2deviceinfo?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2")]
    pub struct MIDI2DeviceInfo;
);

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

#[cfg(feature = "objc2")]
impl MIDI2DeviceInfo {
    extern_methods!(
        #[cfg(feature = "MIDIUMPCI")]
        /// The MIDI System Exclusive ID of the device manufacturer, up to 3-Bytes.
        ///
        /// One-byte SysEx IDs use only the least significant byte (e.g., Apple's System Exclusive ID, 0x11).
        #[unsafe(method(manufacturerID))]
        #[unsafe(method_family = none)]
        pub unsafe fn manufacturerID(&self) -> MIDI2DeviceManufacturer;

        #[cfg(feature = "MIDIMessages")]
        /// The family of models to which the device belongs, up to 14 bits.
        #[unsafe(method(family))]
        #[unsafe(method_family = none)]
        pub unsafe fn family(&self) -> MIDIUInteger14;

        #[cfg(feature = "MIDIMessages")]
        /// The specific model from the device manufacturer, up to 14 bits.
        #[unsafe(method(modelNumber))]
        #[unsafe(method_family = none)]
        pub unsafe fn modelNumber(&self) -> MIDIUInteger14;

        #[cfg(feature = "MIDIUMPCI")]
        /// The version number of a device model number.
        #[unsafe(method(revisionLevel))]
        #[unsafe(method_family = none)]
        pub unsafe fn revisionLevel(&self) -> MIDI2DeviceRevisionLevel;

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

        #[cfg(all(feature = "MIDIMessages", feature = "MIDIUMPCI"))]
        /// The initializer for constructing the MIDI2DeviceInfo object.
        ///
        ///
        /// Parameter `manufacturerID`: The 3-Byte manufacturer System Exclusive ID.
        ///
        /// Parameter `family`: The 14-bit device family.
        ///
        /// Parameter `modelNumber`: The 14-bit model number.
        ///
        /// Parameter `revisionLevel`: The 4-Byte revision level.
        ///
        ///
        /// Provided values for family or modelNumber must be within their expected
        /// bit range. For example, if modelNumber is outside of the range of a 14-bit number.
        #[unsafe(method(initWithManufacturerID:family:modelNumber:revisionLevel:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithManufacturerID_family_modelNumber_revisionLevel(
            this: Allocated<Self>,
            manufacturer_id: MIDI2DeviceManufacturer,
            family: MIDIUInteger14,
            model_number: MIDIUInteger14,
            revision_level: MIDI2DeviceRevisionLevel,
        ) -> Retained<Self>;
    );
}

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

/// The UMP protocols that can be supported by a UMP endpoint.
///
///
/// Support for MIDI 1.0 in Universal Packets, or MIDI-1UP.
///
///
/// Support for MIDI 2.0 protocol.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiumpprotocoloptions?language=objc)
// NS_OPTIONS
#[cfg(feature = "MIDIMessages")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MIDIUMPProtocolOptions(pub MIDIUInteger4);
#[cfg(feature = "MIDIMessages")]
bitflags::bitflags! {
    impl MIDIUMPProtocolOptions: MIDIUInteger4 {
        #[doc(alias = "kMIDIUMPProtocolOptionsMIDI1")]
        const MIDI1 = 1;
        #[doc(alias = "kMIDIUMPProtocolOptionsMIDI2")]
        const MIDI2 = 1<<1;
    }
}

#[cfg(all(feature = "MIDIMessages", feature = "objc2"))]
unsafe impl Encode for MIDIUMPProtocolOptions {
    const ENCODING: Encoding = MIDIUInteger4::ENCODING;
}

#[cfg(all(feature = "MIDIMessages", feature = "objc2"))]
unsafe impl RefEncode for MIDIUMPProtocolOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[cfg(feature = "objc2")]
extern_class!(
    /// An object representating a UMP Endpoint.
    ///
    ///
    /// MIDIUMPEndpoint encapsulates a MIDI source and MIDI destination as a
    /// bidirectional MIDI 2.0 communication node along with any associated stream
    /// configuration metadata.
    ///
    /// 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.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiumpendpoint?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2")]
    pub struct MIDIUMPEndpoint;
);

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

#[cfg(feature = "objc2")]
impl MIDIUMPEndpoint {
    extern_methods!(
        #[cfg(feature = "objc2-foundation")]
        /// The UTF-8 encoded name of the UMP endpoint.
        ///
        ///
        /// The name shall not be any longer than 98 bytes of UTF-8 Text.
        #[unsafe(method(name))]
        #[unsafe(method_family = none)]
        pub unsafe fn name(&self) -> Retained<NSString>;

        #[cfg(feature = "MIDIServices")]
        /// The MIDI protocol currently used by the UMP endpoint.
        #[unsafe(method(MIDIProtocol))]
        #[unsafe(method_family = none)]
        pub unsafe fn MIDIProtocol(&self) -> MIDIProtocolID;

        #[cfg(feature = "MIDIMessages")]
        /// All protocols the UMP endpoint is capable of using for communication.
        #[unsafe(method(supportedMIDIProtocols))]
        #[unsafe(method_family = none)]
        pub unsafe fn supportedMIDIProtocols(&self) -> MIDIUMPProtocolOptions;

        #[cfg(feature = "MIDIServices")]
        /// The MIDI destination for the UMP endpoint.
        #[unsafe(method(MIDIDestination))]
        #[unsafe(method_family = none)]
        pub unsafe fn MIDIDestination(&self) -> MIDIEndpointRef;

        #[cfg(feature = "MIDIServices")]
        /// The MIDI source for the UMP endpoint.
        #[unsafe(method(MIDISource))]
        #[unsafe(method_family = none)]
        pub unsafe fn MIDISource(&self) -> MIDIEndpointRef;

        /// The MIDI 2.0 Device identity information associated with the device.
        #[unsafe(method(deviceInfo))]
        #[unsafe(method_family = none)]
        pub unsafe fn deviceInfo(&self) -> Retained<MIDI2DeviceInfo>;

        #[cfg(feature = "objc2-foundation")]
        /// Serial number (or similar value) uniquely identifying this manufacturer/family/model,
        /// up to 42 bytes of ASCII Text in the ordinal range 32-126.
        #[unsafe(method(productInstanceID))]
        #[unsafe(method_family = none)]
        pub unsafe fn productInstanceID(&self) -> Retained<NSString>;

        /// Indicates if the Function Block state will never change once discovered.
        #[unsafe(method(hasStaticFunctionBlocks))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasStaticFunctionBlocks(&self) -> bool;

        /// Jitter-reduction timestamp receive capability.
        #[unsafe(method(hasJRTSReceiveCapability))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasJRTSReceiveCapability(&self) -> bool;

        /// Jitter-reduction timestamp transmit capability
        #[unsafe(method(hasJRTSTransmitCapability))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasJRTSTransmitCapability(&self) -> bool;

        #[cfg(feature = "MIDIUMPCI")]
        /// Indicates the type of UMP Endpoint, if known.
        #[unsafe(method(endpointType))]
        #[unsafe(method_family = none)]
        pub unsafe fn endpointType(&self) -> MIDIUMPCIObjectBackingType;

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

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

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

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