pub struct FileBrowser { /* private fields */ }Expand description
The application-owned state of a FilePicker.
Create it with a start folder, start reading with FileBrowser::open and pass every
FilePickerMsg to FileBrowser::update; both return the command that reads folders on
a background thread.
While a folder is being read, everything shown stays as it was: the folder, its entries, the
filter and the selection change together only when the answer arrives, so quick reads never
flash an empty or loading state. FileBrowser::loading tells which folder is on its way.
Implementations§
Source§impl FileBrowser
impl FileBrowser
Sourcepub fn new(folder: impl Into<PathBuf>, mode: PickMode) -> Self
pub fn new(folder: impl Into<PathBuf>, mode: PickMode) -> Self
A browser at folder choosing in mode. Nothing is read until FileBrowser::open.
Sourcepub fn extensions(
self,
extensions: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn extensions( self, extensions: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Shows only files with these extensions (without the dot, any case); folders always show.
Sourcepub fn folder(&self) -> &Path
pub fn folder(&self) -> &Path
The folder shown. While another folder is read it stays the one shown until the answer arrives.
Sourcepub fn loading(&self) -> Option<&Path>
pub fn loading(&self) -> Option<&Path>
The folder being read, from FileBrowser::open until its answer arrives.
Whether hidden entries are shown.
Sourcepub fn selected_path(&self) -> Option<PathBuf>
pub fn selected_path(&self) -> Option<PathBuf>
The path of the selected entry, if any.
Sourcepub fn open<Msg: Send + 'static>(
&mut self,
folder: impl Into<PathBuf>,
wrap: impl FnOnce(FilePickerMsg) -> Msg + Send + 'static,
) -> Command<Msg>
pub fn open<Msg: Send + 'static>( &mut self, folder: impl Into<PathBuf>, wrap: impl FnOnce(FilePickerMsg) -> Msg + Send + 'static, ) -> Command<Msg>
Reads folder in the background and goes there when it has been read; wrap turns
picker messages into yours. The folder shown stays until then, and a later open makes
the answer of this one stale.
wrap is a function such as Msg::Picker or a closure that captures what it needs. It
runs once, on the background thread that read the folder, so it must be Send; it is
never copied, so it need not be Clone.
Sourcepub fn update<Msg: Send + 'static>(
&mut self,
message: FilePickerMsg,
wrap: impl FnOnce(FilePickerMsg) -> Msg + Send + 'static,
) -> Command<Msg>
pub fn update<Msg: Send + 'static>( &mut self, message: FilePickerMsg, wrap: impl FnOnce(FilePickerMsg) -> Msg + Send + 'static, ) -> Command<Msg>
Applies a picker message. FilePickerMsg::Chosen changes nothing; act on it yourself.
wrap is used as by open, for the folder a message asks to read.
Trait Implementations§
Source§impl Clone for FileBrowser
impl Clone for FileBrowser
Source§fn clone(&self) -> FileBrowser
fn clone(&self) -> FileBrowser
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for FileBrowser
impl RefUnwindSafe for FileBrowser
impl Send for FileBrowser
impl Sync for FileBrowser
impl Unpin for FileBrowser
impl UnsafeUnpin for FileBrowser
impl UnwindSafe for FileBrowser
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<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