use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern "C" {
pub static CSSearchQueryErrorDomain: &'static NSErrorDomain;
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CSSearchQueryErrorCode(pub NSInteger);
impl CSSearchQueryErrorCode {
#[doc(alias = "CSSearchQueryErrorCodeUnknown")]
pub const Unknown: Self = Self(-2000);
#[doc(alias = "CSSearchQueryErrorCodeIndexUnreachable")]
pub const IndexUnreachable: Self = Self(-2001);
#[doc(alias = "CSSearchQueryErrorCodeInvalidQuery")]
pub const InvalidQuery: Self = Self(-2002);
#[doc(alias = "CSSearchQueryErrorCodeCancelled")]
pub const Cancelled: Self = Self(-2003);
}
unsafe impl Encode for CSSearchQueryErrorCode {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for CSSearchQueryErrorCode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CSSearchQuerySourceOptions(pub NSUInteger);
bitflags::bitflags! {
impl CSSearchQuerySourceOptions: NSUInteger {
#[doc(alias = "CSSearchQuerySourceOptionDefault")]
const Default = 0;
#[doc(alias = "CSSearchQuerySourceOptionAllowMail")]
const AllowMail = 1<<0;
}
}
unsafe impl Encode for CSSearchQuerySourceOptions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for CSSearchQuerySourceOptions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CSSearchQueryContext;
);
extern_conformance!(
unsafe impl NSCoding for CSSearchQueryContext {}
);
extern_conformance!(
unsafe impl NSCopying for CSSearchQueryContext {}
);
unsafe impl CopyingHelper for CSSearchQueryContext {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for CSSearchQueryContext {}
);
extern_conformance!(
unsafe impl NSSecureCoding for CSSearchQueryContext {}
);
impl CSSearchQueryContext {
extern_methods!(
#[unsafe(method(fetchAttributes))]
#[unsafe(method_family = none)]
pub unsafe fn fetchAttributes(&self) -> Retained<NSArray<NSString>>;
#[unsafe(method(setFetchAttributes:))]
#[unsafe(method_family = none)]
pub unsafe fn setFetchAttributes(&self, fetch_attributes: &NSArray<NSString>);
#[unsafe(method(filterQueries))]
#[unsafe(method_family = none)]
pub unsafe fn filterQueries(&self) -> Retained<NSArray<NSString>>;
#[unsafe(method(setFilterQueries:))]
#[unsafe(method_family = none)]
pub unsafe fn setFilterQueries(&self, filter_queries: &NSArray<NSString>);
#[unsafe(method(keyboardLanguage))]
#[unsafe(method_family = none)]
pub unsafe fn keyboardLanguage(&self) -> Option<Retained<NSString>>;
#[unsafe(method(setKeyboardLanguage:))]
#[unsafe(method_family = none)]
pub unsafe fn setKeyboardLanguage(&self, keyboard_language: Option<&NSString>);
#[unsafe(method(sourceOptions))]
#[unsafe(method_family = none)]
pub unsafe fn sourceOptions(&self) -> CSSearchQuerySourceOptions;
#[unsafe(method(setSourceOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn setSourceOptions(&self, source_options: CSSearchQuerySourceOptions);
);
}
impl CSSearchQueryContext {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CSSearchQuery;
);
extern_conformance!(
unsafe impl NSObjectProtocol for CSSearchQuery {}
);
impl CSSearchQuery {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(initWithQueryString:queryContext:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithQueryString_queryContext(
this: Allocated<Self>,
query_string: &NSString,
query_context: Option<&CSSearchQueryContext>,
) -> Retained<Self>;
#[deprecated = "Use initWithQueryString:queryContext instead"]
#[unsafe(method(initWithQueryString:attributes:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithQueryString_attributes(
this: Allocated<Self>,
query_string: &NSString,
attributes: Option<&NSArray<NSString>>,
) -> Retained<Self>;
#[unsafe(method(isCancelled))]
#[unsafe(method_family = none)]
pub unsafe fn isCancelled(&self) -> bool;
#[unsafe(method(foundItemCount))]
#[unsafe(method_family = none)]
pub unsafe fn foundItemCount(&self) -> NSUInteger;
#[cfg(all(feature = "CSSearchableItem", feature = "block2"))]
#[unsafe(method(foundItemsHandler))]
#[unsafe(method_family = none)]
pub unsafe fn foundItemsHandler(
&self,
) -> *mut block2::DynBlock<dyn Fn(NonNull<NSArray<CSSearchableItem>>)>;
#[cfg(all(feature = "CSSearchableItem", feature = "block2"))]
#[unsafe(method(setFoundItemsHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setFoundItemsHandler(
&self,
found_items_handler: Option<
&block2::DynBlock<dyn Fn(NonNull<NSArray<CSSearchableItem>>)>,
>,
);
#[cfg(feature = "block2")]
#[unsafe(method(completionHandler))]
#[unsafe(method_family = none)]
pub unsafe fn completionHandler(&self) -> *mut block2::DynBlock<dyn Fn(*mut NSError)>;
#[cfg(feature = "block2")]
#[unsafe(method(setCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setCompletionHandler(
&self,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[unsafe(method(protectionClasses))]
#[unsafe(method_family = none)]
pub unsafe fn protectionClasses(&self) -> Retained<NSArray<NSFileProtectionType>>;
#[unsafe(method(setProtectionClasses:))]
#[unsafe(method_family = none)]
pub unsafe fn setProtectionClasses(
&self,
protection_classes: &NSArray<NSFileProtectionType>,
);
#[unsafe(method(start))]
#[unsafe(method_family = none)]
pub unsafe fn start(&self);
#[unsafe(method(cancel))]
#[unsafe(method_family = none)]
pub unsafe fn cancel(&self);
);
}
impl CSSearchQuery {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}