pub struct SearchBuilder { /* private fields */ }Expand description
Builder for a Search instance, allowing for more complex searches.
Implementations§
Source§impl SearchBuilder
impl SearchBuilder
Sourcepub fn location(self, location: impl AsRef<Path>) -> Self
pub fn location(self, location: impl AsRef<Path>) -> Self
Set the search location to search in.
§Notes
- Will replace
~with home directory
§Arguments
location- The location to search in.
§Examples
use rust_search::SearchBuilder;
let search: Vec<String> = SearchBuilder::default()
.location("src")
.build()
.collect();Sourcepub fn search_input(self, input: impl Into<String>) -> Self
pub fn search_input(self, input: impl Into<String>) -> Self
Sourcepub fn filter(self, filter: FilterType) -> Self
pub fn filter(self, filter: FilterType) -> Self
Add a filter to the search function.
§Arguments
filter- Closure getting dir:DirEntryvariable to modify
§Examples
use rust_search::{FileSize, FilterExt, SearchBuilder};
use std::time::{Duration, SystemTime};
let search: Vec<String> = SearchBuilder::default()
.location("~/path/to/directory")
.file_size_greater(FileSize::Kilobyte(200.0))
.file_size_smaller(FileSize::Megabyte(10.0))
.created_after(SystemTime::now() - Duration::from_secs(3600 * 24 * 10))
.created_before(SystemTime::now())
.modified_after(SystemTime::now() - Duration::from_secs(3600 * 24 * 5))
.custom_filter(|dir| dir.metadata().unwrap().is_file())
.custom_filter(|dir| !dir.metadata().unwrap().permissions().readonly())
.build()
.collect();Sourcepub fn strict(self) -> Self
pub fn strict(self) -> Self
Searches for exact match.
For example, if the search input is “Search”, the file “Search.rs” will be found, but not “Searcher.rs”.
§Examples
use rust_search::SearchBuilder;
let search: Vec<String> = SearchBuilder::default()
.search_input("name")
.strict()
.build()
.collect();Sourcepub fn ignore_case(self) -> Self
pub fn ignore_case(self) -> Self
Set search option to be case insensitive.
For example, if the search input is “Search”, the file “search.rs” will be found.
§Examples
use rust_search::SearchBuilder;
let search: Vec<String> = SearchBuilder::default()
.search_input("name")
.ignore_case()
.build()
.collect();Searches for hidden files.
§Examples
use rust_search::SearchBuilder;
let search: Vec<String> = SearchBuilder::default()
.with_hidden()
.build()
.collect();Sourcepub fn more_locations(self, more_locations: Vec<impl AsRef<Path>>) -> Self
pub fn more_locations(self, more_locations: Vec<impl AsRef<Path>>) -> Self
Add extra locations to search in, in addition to the main location.
§Notes
- Will replace
~with home directory
§Arguments
more_locations- locations to search in.
§Examples
use rust_search::SearchBuilder;
let search: Vec<String> = SearchBuilder::default()
.more_locations(vec!["/Users/username/b/", "/Users/username/c/"])
.build()
.collect();Trait Implementations§
Source§impl Default for SearchBuilder
impl Default for SearchBuilder
Source§impl FilterExt for SearchBuilder
impl FilterExt for SearchBuilder
Source§fn created_before(self, t: SystemTime) -> Self
fn created_before(self, t: SystemTime) -> Self
files created before
t: SystemTimeSource§fn created_at(self, t: SystemTime) -> Self
fn created_at(self, t: SystemTime) -> Self
files created at
t: SystemTimeSource§fn created_after(self, t: SystemTime) -> Self
fn created_after(self, t: SystemTime) -> Self
files created after
t: SystemTimeSource§fn modified_before(self, t: SystemTime) -> Self
fn modified_before(self, t: SystemTime) -> Self
files created before
t: SystemTimeSource§fn modified_at(self, t: SystemTime) -> Self
fn modified_at(self, t: SystemTime) -> Self
files modified at
t: SystemTimeSource§fn modified_after(self, t: SystemTime) -> Self
fn modified_after(self, t: SystemTime) -> Self
files modified after
t: SystemTimeSource§fn file_size_smaller(self, size: FileSize) -> Self
fn file_size_smaller(self, size: FileSize) -> Self
files smaller than
size_in_bytes: usizeSource§fn file_size_equal(self, size: FileSize) -> Self
fn file_size_equal(self, size: FileSize) -> Self
files equal to
size_in_bytes: usizeSource§fn file_size_greater(self, size: FileSize) -> Self
fn file_size_greater(self, size: FileSize) -> Self
files greater than
size_in_bytes: usizeAuto Trait Implementations§
impl Freeze for SearchBuilder
impl RefUnwindSafe for SearchBuilder
impl Send for SearchBuilder
impl Sync for SearchBuilder
impl Unpin for SearchBuilder
impl UnwindSafe for SearchBuilder
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