use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "dispatch2")]
use dispatch2::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use crate::*;
#[cfg(feature = "objc2-core-foundation")]
pub type ODQueryCallback =
Option<unsafe extern "C-unwind" fn(*mut ODQueryRef, *const CFArray, *mut CFError, *mut c_void)>;
#[cfg(feature = "objc2-core-foundation")]
unsafe impl ConcreteType for ODQueryRef {
#[doc(alias = "ODQueryGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn ODQueryGetTypeID() -> CFTypeID;
}
unsafe { ODQueryGetTypeID() }
}
}
impl ODQueryRef {
#[doc(alias = "ODQueryCreateWithNode")]
#[cfg(all(
feature = "CFOpenDirectoryConstants",
feature = "objc2-core-foundation"
))]
#[inline]
pub unsafe fn with_node(
allocator: Option<&CFAllocator>,
node: Option<&ODNodeRef>,
record_type_or_list: Option<&CFType>,
attribute: Option<&ODAttributeType>,
match_type: ODMatchType,
query_value_or_list: Option<&CFType>,
return_attribute_or_list: Option<&CFType>,
max_results: CFIndex,
error: *mut *mut CFError,
) -> Option<CFRetained<ODQueryRef>> {
extern "C-unwind" {
fn ODQueryCreateWithNode(
allocator: Option<&CFAllocator>,
node: Option<&ODNodeRef>,
record_type_or_list: Option<&CFType>,
attribute: Option<&ODAttributeType>,
match_type: ODMatchType,
query_value_or_list: Option<&CFType>,
return_attribute_or_list: Option<&CFType>,
max_results: CFIndex,
error: *mut *mut CFError,
) -> Option<NonNull<ODQueryRef>>;
}
let ret = unsafe {
ODQueryCreateWithNode(
allocator,
node,
record_type_or_list,
attribute,
match_type,
query_value_or_list,
return_attribute_or_list,
max_results,
error,
)
};
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "ODQueryCreateWithNodeType")]
#[cfg(all(
feature = "CFOpenDirectoryConstants",
feature = "objc2-core-foundation"
))]
#[inline]
pub unsafe fn with_node_type(
allocator: Option<&CFAllocator>,
node_type: ODNodeType,
record_type_or_list: Option<&CFType>,
attribute: Option<&ODAttributeType>,
match_type: ODMatchType,
query_value_or_list: Option<&CFType>,
return_attribute_or_list: Option<&CFType>,
max_results: CFIndex,
error: *mut *mut CFError,
) -> Option<CFRetained<ODQueryRef>> {
extern "C-unwind" {
fn ODQueryCreateWithNodeType(
allocator: Option<&CFAllocator>,
node_type: ODNodeType,
record_type_or_list: Option<&CFType>,
attribute: Option<&ODAttributeType>,
match_type: ODMatchType,
query_value_or_list: Option<&CFType>,
return_attribute_or_list: Option<&CFType>,
max_results: CFIndex,
error: *mut *mut CFError,
) -> Option<NonNull<ODQueryRef>>;
}
let ret = unsafe {
ODQueryCreateWithNodeType(
allocator,
node_type,
record_type_or_list,
attribute,
match_type,
query_value_or_list,
return_attribute_or_list,
max_results,
error,
)
};
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "ODQueryCopyResults")]
#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub unsafe fn results(
&self,
allow_partial_results: bool,
error: *mut *mut CFError,
) -> Option<CFRetained<CFArray>> {
extern "C-unwind" {
fn ODQueryCopyResults(
query: &ODQueryRef,
allow_partial_results: bool,
error: *mut *mut CFError,
) -> Option<NonNull<CFArray>>;
}
let ret = unsafe { ODQueryCopyResults(self, allow_partial_results, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "ODQuerySynchronize")]
#[inline]
pub unsafe fn synchronize(&self) {
extern "C-unwind" {
fn ODQuerySynchronize(query: &ODQueryRef);
}
unsafe { ODQuerySynchronize(self) }
}
#[doc(alias = "ODQuerySetCallback")]
#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub unsafe fn set_callback(&self, callback: ODQueryCallback, user_info: *mut c_void) {
extern "C-unwind" {
fn ODQuerySetCallback(
query: &ODQueryRef,
callback: ODQueryCallback,
user_info: *mut c_void,
);
}
unsafe { ODQuerySetCallback(self, callback, user_info) }
}
#[doc(alias = "ODQueryScheduleWithRunLoop")]
#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub unsafe fn schedule_with_run_loop(
&self,
run_loop: Option<&CFRunLoop>,
run_loop_mode: Option<&CFString>,
) {
extern "C-unwind" {
fn ODQueryScheduleWithRunLoop(
query: &ODQueryRef,
run_loop: Option<&CFRunLoop>,
run_loop_mode: Option<&CFString>,
);
}
unsafe { ODQueryScheduleWithRunLoop(self, run_loop, run_loop_mode) }
}
#[doc(alias = "ODQueryUnscheduleFromRunLoop")]
#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub unsafe fn unschedule_from_run_loop(
&self,
run_loop: Option<&CFRunLoop>,
run_loop_mode: Option<&CFString>,
) {
extern "C-unwind" {
fn ODQueryUnscheduleFromRunLoop(
query: &ODQueryRef,
run_loop: Option<&CFRunLoop>,
run_loop_mode: Option<&CFString>,
);
}
unsafe { ODQueryUnscheduleFromRunLoop(self, run_loop, run_loop_mode) }
}
#[doc(alias = "ODQuerySetDispatchQueue")]
#[cfg(feature = "dispatch2")]
#[inline]
pub unsafe fn set_dispatch_queue(&self, queue: Option<&DispatchQueue>) {
extern "C-unwind" {
fn ODQuerySetDispatchQueue(query: &ODQueryRef, queue: Option<&DispatchQueue>);
}
unsafe { ODQuerySetDispatchQueue(self, queue) }
}
}
#[cfg(all(
feature = "CFOpenDirectoryConstants",
feature = "objc2-core-foundation"
))]
#[deprecated = "renamed to `ODQueryRef::with_node`"]
#[inline]
pub unsafe extern "C-unwind" fn ODQueryCreateWithNode(
allocator: Option<&CFAllocator>,
node: Option<&ODNodeRef>,
record_type_or_list: Option<&CFType>,
attribute: Option<&ODAttributeType>,
match_type: ODMatchType,
query_value_or_list: Option<&CFType>,
return_attribute_or_list: Option<&CFType>,
max_results: CFIndex,
error: *mut *mut CFError,
) -> Option<CFRetained<ODQueryRef>> {
extern "C-unwind" {
fn ODQueryCreateWithNode(
allocator: Option<&CFAllocator>,
node: Option<&ODNodeRef>,
record_type_or_list: Option<&CFType>,
attribute: Option<&ODAttributeType>,
match_type: ODMatchType,
query_value_or_list: Option<&CFType>,
return_attribute_or_list: Option<&CFType>,
max_results: CFIndex,
error: *mut *mut CFError,
) -> Option<NonNull<ODQueryRef>>;
}
let ret = unsafe {
ODQueryCreateWithNode(
allocator,
node,
record_type_or_list,
attribute,
match_type,
query_value_or_list,
return_attribute_or_list,
max_results,
error,
)
};
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(all(
feature = "CFOpenDirectoryConstants",
feature = "objc2-core-foundation"
))]
#[deprecated = "renamed to `ODQueryRef::with_node_type`"]
#[inline]
pub unsafe extern "C-unwind" fn ODQueryCreateWithNodeType(
allocator: Option<&CFAllocator>,
node_type: ODNodeType,
record_type_or_list: Option<&CFType>,
attribute: Option<&ODAttributeType>,
match_type: ODMatchType,
query_value_or_list: Option<&CFType>,
return_attribute_or_list: Option<&CFType>,
max_results: CFIndex,
error: *mut *mut CFError,
) -> Option<CFRetained<ODQueryRef>> {
extern "C-unwind" {
fn ODQueryCreateWithNodeType(
allocator: Option<&CFAllocator>,
node_type: ODNodeType,
record_type_or_list: Option<&CFType>,
attribute: Option<&ODAttributeType>,
match_type: ODMatchType,
query_value_or_list: Option<&CFType>,
return_attribute_or_list: Option<&CFType>,
max_results: CFIndex,
error: *mut *mut CFError,
) -> Option<NonNull<ODQueryRef>>;
}
let ret = unsafe {
ODQueryCreateWithNodeType(
allocator,
node_type,
record_type_or_list,
attribute,
match_type,
query_value_or_list,
return_attribute_or_list,
max_results,
error,
)
};
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "objc2-core-foundation")]
#[deprecated = "renamed to `ODQueryRef::results`"]
#[inline]
pub unsafe extern "C-unwind" fn ODQueryCopyResults(
query: &ODQueryRef,
allow_partial_results: bool,
error: *mut *mut CFError,
) -> Option<CFRetained<CFArray>> {
extern "C-unwind" {
fn ODQueryCopyResults(
query: &ODQueryRef,
allow_partial_results: bool,
error: *mut *mut CFError,
) -> Option<NonNull<CFArray>>;
}
let ret = unsafe { ODQueryCopyResults(query, allow_partial_results, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
extern "C-unwind" {
#[deprecated = "renamed to `ODQueryRef::synchronize`"]
pub fn ODQuerySynchronize(query: &ODQueryRef);
}
extern "C-unwind" {
#[cfg(feature = "objc2-core-foundation")]
#[deprecated = "renamed to `ODQueryRef::set_callback`"]
pub fn ODQuerySetCallback(
query: &ODQueryRef,
callback: ODQueryCallback,
user_info: *mut c_void,
);
}
extern "C-unwind" {
#[cfg(feature = "objc2-core-foundation")]
#[deprecated = "renamed to `ODQueryRef::schedule_with_run_loop`"]
pub fn ODQueryScheduleWithRunLoop(
query: &ODQueryRef,
run_loop: Option<&CFRunLoop>,
run_loop_mode: Option<&CFString>,
);
}
extern "C-unwind" {
#[cfg(feature = "objc2-core-foundation")]
#[deprecated = "renamed to `ODQueryRef::unschedule_from_run_loop`"]
pub fn ODQueryUnscheduleFromRunLoop(
query: &ODQueryRef,
run_loop: Option<&CFRunLoop>,
run_loop_mode: Option<&CFString>,
);
}
extern "C-unwind" {
#[cfg(feature = "dispatch2")]
#[deprecated = "renamed to `ODQueryRef::set_dispatch_queue`"]
pub fn ODQuerySetDispatchQueue(query: &ODQueryRef, queue: Option<&DispatchQueue>);
}