pub struct FilePickerState {
pub current_dir: PathBuf,
pub entries: Vec<FileEntry>,
pub selected: usize,
pub selected_file: Option<PathBuf>,
pub show_hidden: bool,
pub extensions: Vec<String>,
pub dirty: bool,
}Expand description
State for a file picker widget.
Tracks the current directory listing, filtering options, and selected file.
Fields§
§current_dir: PathBufCurrent directory being browsed.
entries: Vec<FileEntry>Visible entries in the current directory.
selected: usizeSelected entry index in entries.
selected_file: Option<PathBuf>Currently selected file path, if any.
Whether dotfiles are included in the listing.
extensions: Vec<String>Allowed file extensions (lowercase, no leading dot).
dirty: boolWhether the directory listing needs refresh.
Implementations§
Source§impl FilePickerState
impl FilePickerState
Configure whether hidden files should be shown.
Sourcepub fn extensions(self, exts: &[&str]) -> Self
pub fn extensions(self, exts: &[&str]) -> Self
Restrict visible files to the provided extensions.
Sourcepub fn selected_file(&self) -> Option<&PathBuf>
pub fn selected_file(&self) -> Option<&PathBuf>
Return the currently selected file path, if any.
Disambiguates from the selected: usize field, which
is the entry index into entries. This method returns
the resolved file path that the user picked via Enter — None until a
file (not a directory) is selected.
§Example
let mut state = FilePickerState::new(".");
if ui.file_picker(&mut state).changed {
if let Some(path) = state.selected_file() {
println!("picked: {}", path.display());
}
}Sourcepub fn selected(&self) -> Option<&PathBuf>
👎Deprecated since 0.20.0: use selected_file() — disambiguates from the selected: usize field index
pub fn selected(&self) -> Option<&PathBuf>
use selected_file() — disambiguates from the selected: usize field index
Return the currently selected file path.
Deprecated alias for selected_file. The
shorter name conflicts visually with the selected: usize
field — a getter returning a path alongside a public field returning
an index made call sites ambiguous. Migrate to selected_file() for
new code; this stub stays callable until v1.0.
Trait Implementations§
Source§impl Clone for FilePickerState
impl Clone for FilePickerState
Source§fn clone(&self) -> FilePickerState
fn clone(&self) -> FilePickerState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more