use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
#[doc(alias = "MDLabelRef")]
#[repr(C)]
pub struct MDLabel {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
cf_type!(
unsafe impl MDLabel {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"__MDLabel"> for MDLabel {}
);
unsafe impl ConcreteType for MDLabel {
#[doc(alias = "MDLabelGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn MDLabelGetTypeID() -> CFTypeID;
}
unsafe { MDLabelGetTypeID() }
}
}
#[cfg(feature = "MDItem")]
impl MDItem {
#[doc(alias = "MDItemCopyLabels")]
#[cfg(feature = "MDItem")]
#[inline]
pub unsafe fn labels(&self) -> Option<CFRetained<CFArray>> {
extern "C-unwind" {
fn MDItemCopyLabels(item: &MDItem) -> Option<NonNull<CFArray>>;
}
let ret = unsafe { MDItemCopyLabels(self) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "MDItemSetLabel")]
#[cfg(feature = "MDItem")]
#[inline]
pub unsafe fn set_label(&self, label: Option<&MDLabel>) -> bool {
extern "C-unwind" {
fn MDItemSetLabel(item: &MDItem, label: Option<&MDLabel>) -> Boolean;
}
let ret = unsafe { MDItemSetLabel(self, label) };
ret != 0
}
#[doc(alias = "MDItemRemoveLabel")]
#[cfg(feature = "MDItem")]
#[inline]
pub unsafe fn remove_label(&self, label: Option<&MDLabel>) -> bool {
extern "C-unwind" {
fn MDItemRemoveLabel(item: &MDItem, label: Option<&MDLabel>) -> Boolean;
}
let ret = unsafe { MDItemRemoveLabel(self, label) };
ret != 0
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MDLabelDomain(pub c_uint);
impl MDLabelDomain {
#[doc(alias = "kMDLabelUserDomain")]
pub const UserDomain: Self = Self(0);
#[doc(alias = "kMDLabelLocalDomain")]
pub const LocalDomain: Self = Self(1);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for MDLabelDomain {
const ENCODING: Encoding = c_uint::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for MDLabelDomain {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
impl MDLabel {
#[doc(alias = "MDLabelCreate")]
#[inline]
pub unsafe fn new(
allocator: Option<&CFAllocator>,
display_name: Option<&CFString>,
kind: Option<&CFString>,
domain: MDLabelDomain,
) -> Option<CFRetained<MDLabel>> {
extern "C-unwind" {
fn MDLabelCreate(
allocator: Option<&CFAllocator>,
display_name: Option<&CFString>,
kind: Option<&CFString>,
domain: MDLabelDomain,
) -> Option<NonNull<MDLabel>>;
}
let ret = unsafe { MDLabelCreate(allocator, display_name, kind, domain) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "MDLabelCopyAttribute")]
#[inline]
pub unsafe fn attribute(&self, name: Option<&CFString>) -> Option<CFRetained<CFType>> {
extern "C-unwind" {
fn MDLabelCopyAttribute(
label: &MDLabel,
name: Option<&CFString>,
) -> Option<NonNull<CFType>>;
}
let ret = unsafe { MDLabelCopyAttribute(self, name) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "MDLabelCopyAttributeName")]
#[inline]
pub unsafe fn attribute_name(&self) -> Option<CFRetained<CFString>> {
extern "C-unwind" {
fn MDLabelCopyAttributeName(label: &MDLabel) -> Option<NonNull<CFString>>;
}
let ret = unsafe { MDLabelCopyAttributeName(self) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "MDLabelDelete")]
#[inline]
pub unsafe fn delete(&self) -> bool {
extern "C-unwind" {
fn MDLabelDelete(label: &MDLabel) -> Boolean;
}
let ret = unsafe { MDLabelDelete(self) };
ret != 0
}
#[doc(alias = "MDLabelSetAttributes")]
#[inline]
pub unsafe fn set_attributes(&self, attrs: Option<&CFDictionary>) -> bool {
extern "C-unwind" {
fn MDLabelSetAttributes(label: &MDLabel, attrs: Option<&CFDictionary>) -> Boolean;
}
let ret = unsafe { MDLabelSetAttributes(self, attrs) };
ret != 0
}
}
#[inline]
pub unsafe extern "C-unwind" fn MDCopyLabelKinds() -> Option<CFRetained<CFArray>> {
extern "C-unwind" {
fn MDCopyLabelKinds() -> Option<NonNull<CFArray>>;
}
let ret = unsafe { MDCopyLabelKinds() };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[inline]
pub unsafe extern "C-unwind" fn MDCopyLabelsMatchingExpression(
simple_query_string: Option<&CFString>,
) -> Option<CFRetained<CFArray>> {
extern "C-unwind" {
fn MDCopyLabelsMatchingExpression(
simple_query_string: Option<&CFString>,
) -> Option<NonNull<CFArray>>;
}
let ret = unsafe { MDCopyLabelsMatchingExpression(simple_query_string) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[inline]
pub unsafe extern "C-unwind" fn MDCopyLabelsWithKind(
kind: Option<&CFString>,
) -> Option<CFRetained<CFArray>> {
extern "C-unwind" {
fn MDCopyLabelsWithKind(kind: Option<&CFString>) -> Option<NonNull<CFArray>>;
}
let ret = unsafe { MDCopyLabelsWithKind(kind) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[inline]
pub unsafe extern "C-unwind" fn MDCopyLabelWithUUID(
label_uuid: Option<&CFUUID>,
) -> Option<CFRetained<MDLabel>> {
extern "C-unwind" {
fn MDCopyLabelWithUUID(label_uuid: Option<&CFUUID>) -> Option<NonNull<MDLabel>>;
}
let ret = unsafe { MDCopyLabelWithUUID(label_uuid) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
extern "C" {
pub static kMDLabelBundleURL: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelContentChangeDate: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelDisplayName: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelIconData: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelIconUUID: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelIsMutuallyExclusiveSetMember: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelKind: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelSetsFinderColor: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelUUID: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelVisibility: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelKindIsMutuallyExclusiveSetKey: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelKindVisibilityKey: Option<&'static CFString>;
}
extern "C" {
pub static kMDPrivateVisibility: Option<&'static CFString>;
}
extern "C" {
pub static kMDPublicVisibility: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelAddedNotification: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelChangedNotification: Option<&'static CFString>;
}
extern "C" {
pub static kMDLabelRemovedNotification: Option<&'static CFString>;
}
#[cfg(feature = "MDItem")]
#[deprecated = "renamed to `MDItem::labels`"]
#[inline]
pub unsafe extern "C-unwind" fn MDItemCopyLabels(item: &MDItem) -> Option<CFRetained<CFArray>> {
extern "C-unwind" {
fn MDItemCopyLabels(item: &MDItem) -> Option<NonNull<CFArray>>;
}
let ret = unsafe { MDItemCopyLabels(item) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "MDItem")]
#[deprecated = "renamed to `MDItem::set_label`"]
#[inline]
pub unsafe extern "C-unwind" fn MDItemSetLabel(item: &MDItem, label: Option<&MDLabel>) -> bool {
extern "C-unwind" {
fn MDItemSetLabel(item: &MDItem, label: Option<&MDLabel>) -> Boolean;
}
let ret = unsafe { MDItemSetLabel(item, label) };
ret != 0
}
#[cfg(feature = "MDItem")]
#[deprecated = "renamed to `MDItem::remove_label`"]
#[inline]
pub unsafe extern "C-unwind" fn MDItemRemoveLabel(item: &MDItem, label: Option<&MDLabel>) -> bool {
extern "C-unwind" {
fn MDItemRemoveLabel(item: &MDItem, label: Option<&MDLabel>) -> Boolean;
}
let ret = unsafe { MDItemRemoveLabel(item, label) };
ret != 0
}
#[deprecated = "renamed to `MDLabel::new`"]
#[inline]
pub unsafe extern "C-unwind" fn MDLabelCreate(
allocator: Option<&CFAllocator>,
display_name: Option<&CFString>,
kind: Option<&CFString>,
domain: MDLabelDomain,
) -> Option<CFRetained<MDLabel>> {
extern "C-unwind" {
fn MDLabelCreate(
allocator: Option<&CFAllocator>,
display_name: Option<&CFString>,
kind: Option<&CFString>,
domain: MDLabelDomain,
) -> Option<NonNull<MDLabel>>;
}
let ret = unsafe { MDLabelCreate(allocator, display_name, kind, domain) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[deprecated = "renamed to `MDLabel::attribute`"]
#[inline]
pub unsafe extern "C-unwind" fn MDLabelCopyAttribute(
label: &MDLabel,
name: Option<&CFString>,
) -> Option<CFRetained<CFType>> {
extern "C-unwind" {
fn MDLabelCopyAttribute(
label: &MDLabel,
name: Option<&CFString>,
) -> Option<NonNull<CFType>>;
}
let ret = unsafe { MDLabelCopyAttribute(label, name) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[deprecated = "renamed to `MDLabel::attribute_name`"]
#[inline]
pub unsafe extern "C-unwind" fn MDLabelCopyAttributeName(
label: &MDLabel,
) -> Option<CFRetained<CFString>> {
extern "C-unwind" {
fn MDLabelCopyAttributeName(label: &MDLabel) -> Option<NonNull<CFString>>;
}
let ret = unsafe { MDLabelCopyAttributeName(label) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[deprecated = "renamed to `MDLabel::delete`"]
#[inline]
pub unsafe extern "C-unwind" fn MDLabelDelete(label: &MDLabel) -> bool {
extern "C-unwind" {
fn MDLabelDelete(label: &MDLabel) -> Boolean;
}
let ret = unsafe { MDLabelDelete(label) };
ret != 0
}
#[deprecated = "renamed to `MDLabel::set_attributes`"]
#[inline]
pub unsafe extern "C-unwind" fn MDLabelSetAttributes(
label: &MDLabel,
attrs: Option<&CFDictionary>,
) -> bool {
extern "C-unwind" {
fn MDLabelSetAttributes(label: &MDLabel, attrs: Option<&CFDictionary>) -> Boolean;
}
let ret = unsafe { MDLabelSetAttributes(label, attrs) };
ret != 0
}