#[repr(C)]pub struct MDQuery { /* private fields */ }
MDQuery
and Metadata
only.Expand description
This is the type of a reference to MDQuerys.
See also Apple’s documentation
Implementations§
Source§impl MDQuery
impl MDQuery
Sourcepub unsafe fn new(
allocator: Option<&CFAllocator>,
query_string: Option<&CFString>,
value_list_attrs: Option<&CFArray>,
sorting_attrs: Option<&CFArray>,
) -> Option<CFRetained<MDQuery>>
pub unsafe fn new( allocator: Option<&CFAllocator>, query_string: Option<&CFString>, value_list_attrs: Option<&CFArray>, sorting_attrs: Option<&CFArray>, ) -> Option<CFRetained<MDQuery>>
Creates a new query with the given query expression.
Parameter allocator
: The CFAllocator which should be used to allocate
memory for the query and its sub-storage. This
parameter may be NULL in which case the current default
CFAllocator is used.
Parameter queryString
: The query expression string for this query. The
syntax for query expressions is explained above in the
header overview documentation.
Parameter valueListAttrs
: An optional array of attribute names. The
query will collect the values of these attributes into
uniqued lists, which can be used or displayed to summarize
the results of the query, or allow a user to further
qualify the items for which they are searching. This
parameter may be NULL if no value lists are desired. Value
list collection increases CPU usage and significantly
increases the memory usage of an MDQuery. The attribute
names are CFStrings.
Parameter sortingAttrs
: An optional array of attribute names. The
query will results of the query based on the values of
these attributes. The first name in the array is used as
the primary sort key, the second as the secondary key, and
so on. The comparison of like-typed values is a simple,
literal comparison. This parameter may be NULL if no
sorting is desired. Sorting increases memory usage and
significantly increases the CPU usage of an MDQuery.
However, when possible, it is almost always cheaper to have
the MDQuery do the sorting, rather than you fetching all
the results and attributes from each of them and doing the
sorting yourself. The attribute names are CFStrings.
Returns: An MDQueryRef, or NULL on failure. If the query string is empty or malformed (invalid syntax), returns NULL.
Sourcepub unsafe fn new_subset(
allocator: Option<&CFAllocator>,
query: Option<&MDQuery>,
query_string: Option<&CFString>,
value_list_attrs: Option<&CFArray>,
sorting_attrs: Option<&CFArray>,
) -> Option<CFRetained<MDQuery>>
pub unsafe fn new_subset( allocator: Option<&CFAllocator>, query: Option<&MDQuery>, query_string: Option<&CFString>, value_list_attrs: Option<&CFArray>, sorting_attrs: Option<&CFArray>, ) -> Option<CFRetained<MDQuery>>
Creates a new query, which is a subset of the given query. Only results matched by the given query can be matched by the query expression of this query.
Parameter allocator
: The CFAllocator which should be used to allocate
memory for the query and its sub-storage. This
parameter may be NULL in which case the current default
CFAllocator is used.
Parameter query
: The parent query of the new query.
Parameter queryString
: The query expression string for this query.
This expression in effect may further restrict the matches
found by the parent query. If the string is empty the
behavior is undefined.
Parameter valueListAttrs
: An optional array of attribute names. The
query will collect the values of these attributes into
uniqued lists, which can be used or displayed to summarize
the results of the query, or allow a user to further
qualify the items for which they are searching. This
parameter may be NULL if no value lists are desired. Value
list collection increases CPU usage and significantly
increases the memory usage of an MDQuery. The attribute
names are CFStrings.
Parameter sortingAttrs
: An optional array of attribute names. The
query will sort results of the query based on the values of
these attributes. The first name in the array is used as
the primary sort key, the second as the secondary key, and
so on. The comparison of like-typed values is a simple,
literal comparison. This parameter may be NULL if no
sorting is desired. Sorting increases memory usage and
significantly increases the CPU usage of an MDQuery.
However, when possible, it is almost always cheaper to have
the MDQuery do the sorting, rather than you fetching all
the results and attributes from each of them and doing the
sorting yourself. The attribute names are CFStrings.
Returns: An MDQueryRef, or NULL on failure. If the query string is empty or malformed (invalid syntax), returns NULL.
Sourcepub unsafe fn new_for_items(
allocator: Option<&CFAllocator>,
query_string: Option<&CFString>,
value_list_attrs: Option<&CFArray>,
sorting_attrs: Option<&CFArray>,
items: Option<&CFArray>,
) -> Option<CFRetained<MDQuery>>
pub unsafe fn new_for_items( allocator: Option<&CFAllocator>, query_string: Option<&CFString>, value_list_attrs: Option<&CFArray>, sorting_attrs: Option<&CFArray>, items: Option<&CFArray>, ) -> Option<CFRetained<MDQuery>>
Creates a new query with the given query expression.
Parameter allocator
: The CFAllocator which should be used to allocate
memory for the query and its sub-storage. This
parameter may be NULL in which case the current default
CFAllocator is used.
Parameter queryString
: The query expression string for this query. The
syntax for query expressions is explained above in the
header overview documentation.
Parameter valueListAttrs
: An optional array of attribute names. The
query will collect the values of these attributes into
uniqued lists, which can be used or displayed to summarize
the results of the query, or allow a user to further
qualify the items for which they are searching. This
parameter may be NULL if no value lists are desired. Value
list collection increases CPU usage and significantly
increases the memory usage of an MDQuery. The attribute
names are CFStrings.
Parameter sortingAttrs
: An optional array of attribute names. The
query will results of the query based on the values of
these attributes. The first name in the array is used as
the primary sort key, the second as the secondary key, and
so on. The comparison of like-typed values is a simple,
literal comparison. This parameter may be NULL if no
sorting is desired. Sorting increases memory usage and
significantly increases the CPU usage of an MDQuery.
However, when possible, it is almost always cheaper to have
the MDQuery do the sorting, rather than you fetching all
the results and attributes from each of them and doing the
sorting yourself. The attribute names are CFStrings.
Parameter items
: An array of items. The query will only return results
in this set.
Returns: An MDQueryRef, or NULL on failure. If the query string is empty or malformed (invalid syntax), returns NULL.
Sourcepub unsafe fn query_string(self: &MDQuery) -> Option<CFRetained<CFString>>
pub unsafe fn query_string(self: &MDQuery) -> Option<CFRetained<CFString>>
Returns the query string of the query.
Parameter query
: The query to be interrogated.
Returns: The query string of the query.
Sourcepub unsafe fn value_list_attributes(
self: &MDQuery,
) -> Option<CFRetained<CFArray>>
pub unsafe fn value_list_attributes( self: &MDQuery, ) -> Option<CFRetained<CFArray>>
Returns the list of attribute names for which the query is collecting the lists of values.
Parameter query
: The query to be interrogated.
Returns: The list of value list attribute names of the query.
Sourcepub unsafe fn sorting_attributes(self: &MDQuery) -> Option<CFRetained<CFArray>>
pub unsafe fn sorting_attributes(self: &MDQuery) -> Option<CFRetained<CFArray>>
Returns the list of attribute names the query is using to sort the results.
Parameter query
: The query to be interrogated.
Returns: The list of sorting attribute names of the query.
Source§impl MDQuery
impl MDQuery
Sourcepub unsafe fn batching_parameters(self: &MDQuery) -> MDQueryBatchingParams
pub unsafe fn batching_parameters(self: &MDQuery) -> MDQueryBatchingParams
Returns the current parameters that control batching of progress notifications.
Parameter query
: The query to be interrogated.
Returns: An MDQueryBatchingParams structure with the current batching parameters.
Sourcepub unsafe fn set_batching_parameters(
self: &MDQuery,
params: MDQueryBatchingParams,
)
pub unsafe fn set_batching_parameters( self: &MDQuery, params: MDQueryBatchingParams, )
Parameter query
: The query whose batching parameters are to be set.
Parameter params
: An MDQueryBatchingParams structure with the batching
parameters to set.
Source§impl MDQuery
impl MDQuery
Sourcepub unsafe fn set_create_result_function(
self: &MDQuery,
func: MDQueryCreateResultFunction,
context: *mut c_void,
cb: *const CFArrayCallBacks,
)
Available on crate feature MDItem
only.
pub unsafe fn set_create_result_function( self: &MDQuery, func: MDQueryCreateResultFunction, context: *mut c_void, cb: *const CFArrayCallBacks, )
MDItem
only.Sets the function used to create the result objects of the MDQuery. If no create function is set on an MDQuery, the default result objects are MDItemRefs. Results created after a create function is set will be created through the given create function, but values created before the function was set (or after it is unset) are not modified. Therefore it is not advisable to change this function after MDQueryExecute() has been called with the query. The create-result function is called lazily as results are requested from a query, so it will not generally be called on all results, if in fact any. This avoids the cost of creating potentially hundreds of thousands of what might be temporary objects.
Parameter query
: The query to whose result create function is to be set.
Parameter func
: The callback function the MDQuery will use to
create its results, such as those returned from
MDQueryGetResultAtIndex(). This parameter
may be NULL, in which case any previous result creation
settings are cancelled, and the MDQuery will subsequently
produce MDItemRefs. If the function (when the parameter is
not NULL) is not of type MDQueryCreateResultFunction or
does not behave as a MDQueryCreateResultFunction must,
the behavior is undefined.
Parameter context
: A pointer-sized user-defined value, which is
passed as the third parameter to the create function,
but is otherwise unused by MDQuery. The MDQuery does
not retain the context in any way, so it must remain
valid for at least the lifetime of the query. If the
context is not what is expected by the create function,
the behavior is undefined.
Parameter cb
: A pointer to a CFArrayCallBacks structure
initialized with the callbacks for the query to use to
manage the created result objects. A copy of the
contents of the callbacks structure is made, so that a
pointer to a structure on the stack can be passed in, or
can be reused for multiple query creations. Only version
0 of the CFArrayCallBacks is supported. The retain field
may be NULL, in which case the MDQuery will do nothing to
add a retain to the created results for the query. The
release field may be NULL, in which case the MDQuery will
do nothing to remove the query’s retain (such as the one
it gets from the create function) on the result objects
when the query is destroyed. If the copyDescription field
is NULL, the query will create a simple description for
the result objects. If the equal field is NULL, the query
will use pointer equality to test for equality of results.
This callbacks parameter itself may be NULL, which is
treated as if a valid structure of version 0 with all
fields NULL had been passed in. Otherwise, if any of the
fields are not valid pointers to functions of the correct
type, or this parameter is not a valid pointer to a
CFArrayCallBacks callbacks structure, the behavior is
undefined. If any of the value values returned from the
create function is not one understood by one or more of
the callback functions, the behavior when those callback
functions are used is undefined. For example, if the create
function can return NULL, then NULL must be understood by
the callback functions as a possible parameter. The retain
and release callbacks must be a matched set – do not
assume that the retain function will be unused or that
additional reference counts will not be taken on the
created results.
Source§impl MDQuery
impl MDQuery
Sourcepub unsafe fn set_create_value_function(
self: &MDQuery,
func: MDQueryCreateValueFunction,
context: *mut c_void,
cb: *const CFArrayCallBacks,
)
pub unsafe fn set_create_value_function( self: &MDQuery, func: MDQueryCreateValueFunction, context: *mut c_void, cb: *const CFArrayCallBacks, )
Sets the function used to create the value objects of the MDQuery. These are the values of the value lists that were requested when the query was created. If no create function is set on an MDQuery, the default value objects are the CFTypeRef values of the attributes. Values created after a create function is set will be created through the given create function, but values created before the function was set (or after it is unset) are not modified. Therefore it is not advisable to change this function after MDQueryExecute() has been called with the query.
Parameter query
: The query to whose value create function is to be set.
Parameter func
: The callback function the MDQuery will use to
create the value list values, such as those returned from
MDQueryCopyValuesOfAttribute(). This parameter
may be NULL, in which case any previous value creation
settings are cancelled, and the MDQuery will subsequently
produce the default CFTypeRefs. If the function (when the
parameter is not NULL) is not of type
MDQueryCreateValueFunction or does not behave as a
MDQueryCreateValueFunction must, the behavior is undefined.
Parameter context
: A pointer-sized user-defined value, which is
passed as the fourth parameter to the create function,
but is otherwise unused by MDQuery. The MDQuery does
not retain the context in any way, so it must remain
valid for at least the lifetime of the query. If the
context is not what is expected by the create function,
the behavior is undefined.
Parameter cb
: A pointer to a CFArrayCallBacks structure
initialized with the callbacks for the query to use to
manage the created value objects. A copy of the
contents of the callbacks structure is made, so that a
pointer to a structure on the stack can be passed in, or
can be reused for multiple query creations. Only version
0 of the CFArrayCallBacks is supported. The retain field
may be NULL, in which case the MDQuery will do nothing to
add a retain to the created values for the query. The
release field may be NULL, in which case the MDQuery will
do nothing to remove the query’s retain (such as the one
it gets from the create function) on the value objects
when the query is destroyed. If the copyDescription field
is NULL, the query will create a simple description for
the value objects. If the equal field is NULL, the query
will use pointer equality to test for equality of values.
This callbacks parameter itself may be NULL, which is
treated as if a valid structure of version 0 with all
fields NULL had been passed in. Otherwise, if any of the
fields are not valid pointers to functions of the correct
type, or this parameter is not a valid pointer to a
CFArrayCallBacks callbacks structure, the behavior is
undefined. If any of the value values returned from the
create function is not one understood by one or more of
the callback functions, the behavior when those callback
functions are used is undefined. For example, if the
create function can return NULL, then NULL must be
understood by the callback functions as a possible
parameter. The retain and release callbacks must be a
matched set – do not assume that the retain function will
be unused or that additional reference counts will not be
taken on the created values.
Sourcepub unsafe fn set_dispatch_queue(self: &MDQuery, queue: Option<&DispatchQueue>)
Available on crate feature dispatch2
only.
pub unsafe fn set_dispatch_queue(self: &MDQuery, queue: Option<&DispatchQueue>)
dispatch2
only.Set the dispatch queue on which query results will be delivered by MDQueryExecute. It is not advisable to change set dispatch queue after MDQueryExecute() has been called with the query. Setting the dispatch queue for a synchronous query (kMDQuerySynchronous) has no effect.
Parameter query
: The query for which the dispatch queue should be set.
Parameter queue
: The dispatch queue on which results should be delivered.
Sourcepub unsafe fn execute(self: &MDQuery, option_flags: CFOptionFlags) -> bool
pub unsafe fn execute(self: &MDQuery, option_flags: CFOptionFlags) -> bool
Run the query, and populate the query with the results. Queries only gather results or process updates while the current thread’s run loop is running. Queries normally operate asynchronously, and send out progress and update notifications to report changes to the list of results that has been collected. Queries have two phases: the initial gathering of all currently matching results, and a second live-update phase where queries monitor the state of the system and update themselves to external changes in files or the operating environment (for example, as time advances, files which did not match the query when it was started may later match the query). Query notifications are posted within the context of the same thread which executes the query. [[There are three operational modes: (1) synchronous static queries, which collect the list of current results and then do not watch for updates to the results, (2) asynchronous static queries, which collect the results asychronously after this function returns, and then do not watch for updates to the results, and (3) asynchronous live queries which collect the initial results asychronously after this function returns, and then do watch for updates to the results, until the query is destroyed. There is little reason not to allow the fourth case, synchronous collection of initial results, followed by asynchronous monitoring for updates, so this may change in the future.]]
Parameter query
: The query to execute.
Parameter optionFlags
: Bitwise or of MDQueryOptionFlags
Returns: Returns true if the query was started (executed in the case of a synchronous query), false otherwise. Queries cannot be executed more than once.
Sourcepub unsafe fn stop(self: &MDQuery)
pub unsafe fn stop(self: &MDQuery)
Stops the query from ever generating more results. Queries may be executed only once, so a stopped query cannot be restarted. The query will also not generate any result updates. The query is static after this function returns. The query will do final processing of results that have come in but not yet been processed (because, say, the batching parameters hasn’t triggered that yet). That may trigger a progress notification, so be aware of that if you are stopping a query from within your progress note handler; that is, during this function, a recursive progress and/or finished notification might occur, which might recursively call your notification handler. It is safe to call this function recursively. You would call this function to stop a query that is generating way too many results to be useful, but still want to access the results that have come in so far. If a query is stopped before the gathering phase finishes, it will not report itself as finished, nor will it send out a finished notification.
Parameter query
: The query to stop.
Sourcepub unsafe fn disable_updates(self: &MDQuery)
pub unsafe fn disable_updates(self: &MDQuery)
Disables updates to the query result list. This should be called before iterating through the list of results to prevent the result list from changing during the iteration. The disabled state is a counter, and disabling can be done recursively and from different threads.
Parameter query
: The query for which updates are to be disabled.
Returns: The generation number of the query. This changes each time the query’s result set has changed.
Sourcepub unsafe fn enable_updates(self: &MDQuery)
pub unsafe fn enable_updates(self: &MDQuery)
Re-enables updates to the query result list. This should be called when finished iterating through the list of results, to allow changes to the result list to occur. Changes will be allowed when all the disables have been matched by a corresponding enable.
Parameter query
: The query for which updates are to be enabled.
Sourcepub unsafe fn is_gathering_complete(self: &MDQuery) -> bool
pub unsafe fn is_gathering_complete(self: &MDQuery) -> bool
Returns true if the first phase of a query, the initial result gathering, has finished.
Parameter query
: The query to be interrogated.
Returns: A boolean indicating whether or not the first phase of a query has completed.
Sourcepub unsafe fn result_count(self: &MDQuery) -> CFIndex
pub unsafe fn result_count(self: &MDQuery) -> CFIndex
Returns the number of results currently collected by the query. Note that the number of results in a query will change over time as the query’s result list is updated.
Parameter query
: The query to be interrogated.
Returns: The number of results in the query.
Sourcepub unsafe fn result_at_index(self: &MDQuery, idx: CFIndex) -> *const c_void
pub unsafe fn result_at_index(self: &MDQuery, idx: CFIndex) -> *const c_void
Returns the current result at the given index. This function causes the result object to be created if it hasn’t been created already. For performance reasons, it is not advisable to ask for results that you don’t need, to avoid the cost of creating them. If possible, call this function to fetch only the results you need to display or otherwise process. Note that the index of a particular result will change over time, as the query’s result list is updated.
Parameter query
: The query to be interrogated.
Parameter idx
: The index into the query’s result list. If the index is
negative, or is equal to or larger than the current
number of results in the query, the behavior is undefined.
Returns: Returns the MDItemRef currently at the given index, or if a result-create function has been set, returns the result returned by that function.
Sourcepub unsafe fn index_of_result(self: &MDQuery, result: *const c_void) -> CFIndex
pub unsafe fn index_of_result(self: &MDQuery, result: *const c_void) -> CFIndex
Returns the current index of the given result. If a result-create function has been set, and the equal callback is non-NULL, it will be used to test the query’s results against the candidate result. Note that the index of a result will change over time, as the query’s result list is updated.
Parameter query
: The query to be interrogated.
Parameter result
: The candidate result object for which to search.
If a custom create-result function has been set, and this
parameter is not a valid result object that the provided
callbacks can handle, the behavior is undefined. If a custom
create-result function has not been set, this parameter
must be a valid MDItemRef.
Returns: The index of the given result, or kCFNotFound if the value is not one of the query’s existing results. If you provided a custom result creation function, as well as a custom object comparator function, result will be objects created by that function.
Sourcepub unsafe fn attribute_value_of_result_at_index(
self: &MDQuery,
name: Option<&CFString>,
idx: CFIndex,
) -> *mut c_void
pub unsafe fn attribute_value_of_result_at_index( self: &MDQuery, name: Option<&CFString>, idx: CFIndex, ) -> *mut c_void
Returns the value of the named attribute for the result at the given index.
Parameter query
: The query to be interrogated.
Parameter name
: The attribute name for which to return the values.
If the attribute is not one of those requested in the
valueListAttrs or sortingAttrs parameters to one of
the query creation functions, the result will be NULL.
Parameter idx
: The index into the query’s result list. If the index is
negative, or is equal to or larger than the current
number of results in the query, the behavior is undefined.
Returns: The value of the attribute, or NULL if the attribute doesn’t exist in the query on that result.
Sourcepub unsafe fn values_of_attribute(
self: &MDQuery,
name: Option<&CFString>,
) -> Option<CFRetained<CFArray>>
pub unsafe fn values_of_attribute( self: &MDQuery, name: Option<&CFString>, ) -> Option<CFRetained<CFArray>>
Returns the list of values, from the results of the query, of the named attribute. The list is not ordered in any way. The list contains only one occurrence of each value. Note that this list may change over time, as the query’s result list is updated.
Parameter query
: The query to be interrogated.
Parameter name
: The attribute name for which to return the values.
If the attribute is not one of those requested in the
valueListAttrs parameter to one of the query creation
functions, the behavior is undefined.
Returns: A CFArray holding the value objects for that attribute.
Sourcepub unsafe fn count_of_results_with_attribute_value(
self: &MDQuery,
name: Option<&CFString>,
value: Option<&CFType>,
) -> CFIndex
pub unsafe fn count_of_results_with_attribute_value( self: &MDQuery, name: Option<&CFString>, value: Option<&CFType>, ) -> CFIndex
Returns the number of results which have the given attribute and attribute value. Note that this count may change over time, as the query’s result list is updated.
Parameter query
: The query to be interrogated.
Parameter name
: The attribute name for which to return the number
of results with the given value. If the attribute is not
one of those requested in the valueListAttrs parameter to
one of the query creation functions, the behavior is
undefined.
Parameter value
: The attribute value for which to return the number
of results with that value. This parameter may be NULL,
in which case the number of results that do not contain
the named attribute is returned.
Returns: The number of results with that attribute and value.
Sourcepub unsafe fn set_sort_order(
self: &MDQuery,
sorting_attrs: Option<&CFArray>,
) -> bool
pub unsafe fn set_sort_order( self: &MDQuery, sorting_attrs: Option<&CFArray>, ) -> bool
Sets the sort order for a query.
Parameter query
: The query for which the sort order is to be set.
Parameter sortingAttrs
: An array of attribute names, as in MDQueryCreate.
The query’s result set will be sorted according to the order of
these attributes. All names in the array have to have been passed
as sortingAttrs when the query was created. The attribute names
are CFStrings
Returns: A boolean, true on success, false on failure.
Source§impl MDQuery
impl MDQuery
Sourcepub unsafe fn set_sort_option_flags_for_attribute(
self: &MDQuery,
field_name: Option<&CFString>,
flags: u32,
) -> bool
pub unsafe fn set_sort_option_flags_for_attribute( self: &MDQuery, field_name: Option<&CFString>, flags: u32, ) -> bool
Sets the sort flags for a query.
Parameter query
: The query for which the sort flags is to be set.
Parameter fieldName
: The attribute name for which sort option flags are to be set.
The attribute name must have been part of the sortingFlags when the query was created.
Parameter flags
: A uint32_t containing MDQuerySortOptionFlags to be applied to the attibute
Returns: A boolean, true on success, false on failure.
Sourcepub unsafe fn sort_option_flags_for_attribute(
self: &MDQuery,
field_name: Option<&CFString>,
) -> u32
pub unsafe fn sort_option_flags_for_attribute( self: &MDQuery, field_name: Option<&CFString>, ) -> u32
Gets the sort option flags for a sorting attribute.
Parameter query
: The query for which fetch sort option flags.
Parameter fieldName
: The attribute name for which sort option flags are to be fetched.
Returns: A uint32_t, with MDQuerySortOptionFlags set for the attribute.
Source§impl MDQuery
impl MDQuery
Sourcepub unsafe fn set_sort_comparator(
self: &MDQuery,
comparator: MDQuerySortComparatorFunction,
context: *mut c_void,
)
pub unsafe fn set_sort_comparator( self: &MDQuery, comparator: MDQuerySortComparatorFunction, context: *mut c_void, )
Sets the function used to sort the results of an MDQuery. You may set the comparator function as many times as you like, even while the query is executing. Whenever the comparator function is set, all results are re-sorted using the new comparator function before the function returns. The function pointer can be NULL to cancel custom sorting and revert to the default sorting. The default sort provided by MDQueryCreate() is a assending sort strings are compared using CFStringCompare() with the options kCFCompareNonliteral | kCFCompareLocalized | kCFCompareNumerically. CFDataRefs are compared by using memcmp() of the data pointers.
Parameter query
: The query to whose result sort function is to be set.
Parameter func
: The callback function the MDQuery will use to
sort its results. If the function (when the parameter is
not NULL) is not of type MDQuerySortComparatorFunction or
does not behave as a MDQuerySortComparatorFunction must,
the behavior is undefined. The function pointer may
be NULL to cancel any custom comparator.
Parameter context
: A pointer-sized user-defined value, which is
passed as the third parameter to the sort function,
but is otherwise unused by MDQuery. The MDQuery does
not retain the context in any way, so it must remain
valid for the lifetime of the query or until the sort
function is set again. If the context is not what is
expected by the comparator, the behavior is undefined.
pub unsafe fn set_sort_comparator_block( self: &MDQuery, comparator: Option<&DynBlock<dyn Fn(*mut *const CFType, *mut *const CFType) -> CFComparisonResult>>, )
block2
only.Source§impl MDQuery
impl MDQuery
Sourcepub unsafe fn set_search_scope(
self: &MDQuery,
scope_directories: Option<&CFArray>,
scope_options: u32,
)
pub unsafe fn set_search_scope( self: &MDQuery, scope_directories: Option<&CFArray>, scope_options: u32, )
Use MDQuerySetSearchScope to limit the results returned by the query engine to those MDItemRefs that appear within the specified directories. This may be used to limit searching to particular volumes. Tilde paths, or environment variables are not expanded. Calling this multiple times will replace the previous options. This must be called before the query is executed.
Parameter query
: The query object to modify.
Parameter scopeDirectories
: a CFArray of CFStringRef or CFURLRef objects which
specify where to search. For conveinience, the kMDQueryScopeHome,
kMDQueryScopeComputer and kMDQueryScopeNetwork constants may also
be present in this array.
Parameter scopeOptions
: additional options for modifying the search.
Currently, pass 0 (zero).
Source§impl MDQuery
impl MDQuery
Sourcepub unsafe fn set_max_count(self: &MDQuery, size: CFIndex)
pub unsafe fn set_max_count(self: &MDQuery, size: CFIndex)
Use MDQuerySetMaxCount to limit the number of results returned by the query engine. This must be called before the query is executed.
Parameter query
: The query object to modify.
Parameter size
: The maximum number of results desired.
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Available on crate features SearchKit
and SKDocument
only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
SearchKit
and SKDocument
only.Attempt to downcast the type to that of type T
.
This is the reference-variant. Use CFRetained::downcast
if you
want to convert a retained type. See also ConcreteType
for more
details on which types support being converted to.
Sourcepub fn retain_count(&self) -> usize
Available on crate features SearchKit
and SKDocument
only.
pub fn retain_count(&self) -> usize
SearchKit
and SKDocument
only.Get the reference count of the object.
This function may be useful for debugging. You normally do not use this function otherwise.
Beware that some things (like CFNumber
s, small CFString
s etc.) may
not have a normal retain count for optimization purposes, and can
return usize::MAX
in that case.
Trait Implementations§
Source§impl ConcreteType for MDQuery
impl ConcreteType for MDQuery
Source§impl RefEncode for MDQuery
impl RefEncode for MDQuery
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for MDQuery
impl Type for MDQuery
Source§fn retain(&self) -> CFRetained<Self>where
Self: Sized,
fn retain(&self) -> CFRetained<Self>where
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation
crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation
crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation
crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation
crate. Read more