objc2-core-services 0.3.2

Bindings to the CoreServices 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::*;
use objc2_core_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/lslaunchflags?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct LSLaunchFlags(pub OptionBits);
bitflags::bitflags! {
    impl LSLaunchFlags: OptionBits {
        #[doc(alias = "kLSLaunchDefaults")]
        const Defaults = 0x00000001;
        #[doc(alias = "kLSLaunchAndPrint")]
        const AndPrint = 0x00000002;
        #[doc(alias = "kLSLaunchAndDisplayErrors")]
        const AndDisplayErrors = 0x00000040;
        #[doc(alias = "kLSLaunchDontAddToRecents")]
        const DontAddToRecents = 0x00000100;
        #[doc(alias = "kLSLaunchDontSwitch")]
        const DontSwitch = 0x00000200;
        #[doc(alias = "kLSLaunchAsync")]
        const Async = 0x00010000;
        #[doc(alias = "kLSLaunchNewInstance")]
        const NewInstance = 0x00080000;
        #[doc(alias = "kLSLaunchAndHide")]
        const AndHide = 0x00100000;
        #[doc(alias = "kLSLaunchAndHideOthers")]
        const AndHideOthers = 0x00200000;
    }
}

#[cfg(feature = "objc2")]
unsafe impl Encode for LSLaunchFlags {
    const ENCODING: Encoding = OptionBits::ENCODING;
}

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

/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/lslaunchurlspec?language=objc)
#[cfg(all(feature = "AE", feature = "AEDataModel"))]
#[repr(C, packed(2))]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct LSLaunchURLSpec {
    pub appURL: *const CFURL,
    pub itemURLs: *const CFArray,
    pub passThruParams: *const AEDesc,
    pub launchFlags: LSLaunchFlags,
    pub asyncRefCon: *mut c_void,
}

#[cfg(all(feature = "AE", feature = "AEDataModel", feature = "objc2"))]
unsafe impl Encode for LSLaunchURLSpec {
    const ENCODING: Encoding = Encoding::Struct(
        "LSLaunchURLSpec",
        &[
            <*const CFURL>::ENCODING,
            <*const CFArray>::ENCODING,
            <*const AEDesc>::ENCODING,
            <LSLaunchFlags>::ENCODING,
            <*mut c_void>::ENCODING,
        ],
    );
}

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

extern "C-unwind" {
    /// # Safety
    ///
    /// `out_launched_url` must be a valid pointer or null.
    pub fn LSOpenCFURLRef(in_url: &CFURL, out_launched_url: *mut *const CFURL) -> OSStatus;
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `in_launch_spec` must be a valid pointer.
    /// - `out_launched_url` must be a valid pointer or null.
    #[cfg(all(feature = "AE", feature = "AEDataModel"))]
    pub fn LSOpenFromURLSpec(
        in_launch_spec: NonNull<LSLaunchURLSpec>,
        out_launched_url: *mut *const CFURL,
    ) -> OSStatus;
}