pub struct FileExplorerBuilder { /* private fields */ }Expand description
Builder for creating a FileExplorer.
By default, the builder create FileExplorer with a working directory set to the current one.
Implementations§
Source§impl FileExplorerBuilder
impl FileExplorerBuilder
Sourcepub fn working_dir<P: Into<PathBuf>>(self, working_dir: P) -> Self
pub fn working_dir<P: Into<PathBuf>>(self, working_dir: P) -> Self
Set the current working directory for the FileExplorer.
If not set, it defaults to the current directory.
§Examples
Suppose you have this tree file:
/
├── .git
└── Documents
├── passport.png
└── resume.pdfYou can create a new FileExplorer like this:
let file_explorer = FileExplorerBuilder::default()
.working_dir("/Documents")
.build()
.unwrap();
assert_eq!(file_explorer.cwd().display().to_string(), "/Documents");Sourcepub fn working_file<P: Into<PathBuf>>(self, working_file: P) -> Self
pub fn working_file<P: Into<PathBuf>>(self, working_file: P) -> Self
Same as working_dir but will pre-select the file in the working directory.
This method set the working directory to the parent directory of the provided file and select the file in the file explorer.
You can also select a directory (eg. select /Documents inside /).
§Examples
Suppose you have this tree file:
/
├── .git
└── Documents
├── passport.png
└── resume.pdfYou can create a new FileExplorer selecting passport.png like this:
let file_explorer = FileExplorerBuilder::default()
.working_file("/Documents/passport.png")
.build()
.unwrap();
assert_eq!(file_explorer.cwd().display().to_string(), "/Documents");
assert_eq!(file_explorer.current().path.display().to_string(), "/Documents/passport.png");Set whether to show hidden files in the FileExplorer. Defaults to false.
Sourcepub fn filter_map(
self,
f: impl Fn(File) -> Option<File> + Send + Sync + 'static,
) -> Self
pub fn filter_map( self, f: impl Fn(File) -> Option<File> + Send + Sync + 'static, ) -> Self
Set a filter and map for the FileExplorer.
If not set, all files are shown. Hidden files are filtered before this filter will be apply.
§Examples
let file_explorer = FileExplorerBuilder::default()
.filter_map(|file| if file.is_dir { Some(file) } else { None })
.build()
.unwrap();
/* Only directories are shown */Sourcepub fn theme(self, theme: Theme) -> Self
pub fn theme(self, theme: Theme) -> Self
Set the theme for the FileExplorer.
If not set, it defaults to Theme::new.
§Examples
let file_explorer = FileExplorerBuilder::default()
.theme(Theme::default().add_default_title())
.build()
.unwrap();Sourcepub fn build(self) -> Result<FileExplorer>
pub fn build(self) -> Result<FileExplorer>
Build the FileExplorer instance based on the provided configuration.
§Errors
Will return Err if the setted working directory can not be listed.
Will return Err if NO working directory have been setted and current working directory can not be listed.
See current_dir for more information.
Sourcepub fn build_with_theme(theme: Theme) -> Result<FileExplorer>
pub fn build_with_theme(theme: Theme) -> Result<FileExplorer>
Shortcut method to create a FileExplorer with a custom theme.
See theme for more information about the theme configuration.
Sourcepub fn build_with_working_dir<P: Into<PathBuf>>(
working_dir: P,
) -> Result<FileExplorer>
pub fn build_with_working_dir<P: Into<PathBuf>>( working_dir: P, ) -> Result<FileExplorer>
Shortcut method to create a FileExplorer with a custom working directory.
See working_dir for more information about the working directory configuration.
Sourcepub fn build_with_working_file<P: Into<PathBuf>>(
working_dir: P,
) -> Result<FileExplorer>
pub fn build_with_working_file<P: Into<PathBuf>>( working_dir: P, ) -> Result<FileExplorer>
Shortcut method to create a FileExplorer with a custom working directory and file.
See working_file for more information about the working directory configuration.
Trait Implementations§
Source§impl Clone for FileExplorerBuilder
impl Clone for FileExplorerBuilder
Source§fn clone(&self) -> FileExplorerBuilder
fn clone(&self) -> FileExplorerBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileExplorerBuilder
impl Debug for FileExplorerBuilder
Source§impl Default for FileExplorerBuilder
impl Default for FileExplorerBuilder
Source§fn default() -> FileExplorerBuilder
fn default() -> FileExplorerBuilder
impl Eq for FileExplorerBuilder
Source§impl Hash for FileExplorerBuilder
impl Hash for FileExplorerBuilder
Source§impl PartialEq for FileExplorerBuilder
impl PartialEq for FileExplorerBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for FileExplorerBuilder
impl !UnwindSafe for FileExplorerBuilder
impl Freeze for FileExplorerBuilder
impl Send for FileExplorerBuilder
impl Sync for FileExplorerBuilder
impl Unpin for FileExplorerBuilder
impl UnsafeUnpin for FileExplorerBuilder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more