pub struct MDQueryBuilder { /* private fields */ }Expand description
Builder for constructing MDQuery instances with a fluent interface.
This builder allows for creating complex metadata queries on macOS using the Spotlight search technology. It provides methods to build search expressions that can be combined with logical AND operations.
§Examples
use mdquery_rs::{MDQueryBuilder, MDQueryScope};
// Find files containing "document" in their name
let query = MDQueryBuilder::default()
.name_like("document")
.build(vec![MDQueryScope::Home], None)
.unwrap();
let results = query.execute().unwrap();
for item in results {
println!("{:?}", item.path());
}Implementations§
Source§impl MDQueryBuilder
impl MDQueryBuilder
Sourcepub fn build(
self,
scopes: Vec<MDQueryScope>,
max_count: Option<usize>,
) -> Result<MDQuery>
pub fn build( self, scopes: Vec<MDQueryScope>, max_count: Option<usize>, ) -> Result<MDQuery>
Builds the final MDQuery with the current expressions.
§Parameters
scopes- List of search scopes to apply (e.g., Home, Computer)max_count- Optional maximum number of results to return
§Returns
A Result containing the MDQuery if successful, or an error if no expressions were added.
§Errors
Returns an error if no expressions were added to the builder.
Sourcepub fn from_condition(condition: MDQueryCondition) -> Self
pub fn from_condition(condition: MDQueryCondition) -> Self
Sourcepub fn time(self, key: MDItemKey, op: MDQueryCompareOp, timestamp: i64) -> Self
pub fn time(self, key: MDItemKey, op: MDQueryCompareOp, timestamp: i64) -> Self
Sourcepub fn size(self, op: MDQueryCompareOp, size: u64) -> Self
pub fn size(self, op: MDQueryCompareOp, size: u64) -> Self
Sourcepub fn is_app(self) -> Self
pub fn is_app(self) -> Self
Adds an expression to filter items based on whether they are application bundles.
§Returns
Self for method chaining
Sourcepub fn content_type(self, content_type: &str) -> Self
pub fn content_type(self, content_type: &str) -> Self
Trait Implementations§
Source§impl Default for MDQueryBuilder
impl Default for MDQueryBuilder
Source§fn default() -> MDQueryBuilder
fn default() -> MDQueryBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MDQueryBuilder
impl RefUnwindSafe for MDQueryBuilder
impl Send for MDQueryBuilder
impl Sync for MDQueryBuilder
impl Unpin for MDQueryBuilder
impl UnwindSafe for MDQueryBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more