pub struct FilePicker { /* private fields */ }Expand description
A file picker field for selecting files and directories.
The FilePicker field allows users to browse the filesystem and select files or directories. It can be configured to filter by file type, show/hide hidden files, and control whether files and/or directories can be selected.
§Example
ⓘ
use huh::FilePicker;
let picker = FilePicker::new()
.key("config_file")
.title("Select Configuration File")
.description("Choose a .toml or .json file")
.allowed_types(vec![".toml".to_string(), ".json".to_string()])
.current_directory(".");Implementations§
Source§impl FilePicker
impl FilePicker
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Sets the description.
Sourcepub fn current_directory(self, dir: impl Into<String>) -> Self
pub fn current_directory(self, dir: impl Into<String>) -> Self
Sets the starting directory.
Sourcepub fn allowed_types(self, types: Vec<String>) -> Self
pub fn allowed_types(self, types: Vec<String>) -> Self
Sets the allowed file types (extensions).
Sets whether to show hidden files.
Sourcepub fn show_permissions(self, show: bool) -> Self
pub fn show_permissions(self, show: bool) -> Self
Sets whether to show file permissions.
Sourcepub fn file_allowed(self, allowed: bool) -> Self
pub fn file_allowed(self, allowed: bool) -> Self
Sets whether files can be selected.
Sourcepub fn dir_allowed(self, allowed: bool) -> Self
pub fn dir_allowed(self, allowed: bool) -> Self
Sets whether directories can be selected.
Sourcepub fn validate(self, validate: fn(&str) -> Option<String>) -> Self
pub fn validate(self, validate: fn(&str) -> Option<String>) -> Self
Sets the validation function.
Sourcepub fn height_entries(self, height: usize) -> Self
pub fn height_entries(self, height: usize) -> Self
Sets the visible height (number of entries shown).
Sourcepub fn get_selected_path(&self) -> Option<&str>
pub fn get_selected_path(&self) -> Option<&str>
Gets the currently selected path.
Trait Implementations§
Source§impl Default for FilePicker
impl Default for FilePicker
Source§impl Field for FilePicker
impl Field for FilePicker
Source§fn with_theme(&mut self, theme: &Theme)
fn with_theme(&mut self, theme: &Theme)
Sets the theme.
Source§fn with_keymap(&mut self, keymap: &KeyMap)
fn with_keymap(&mut self, keymap: &KeyMap)
Sets the keymap.
Source§fn with_width(&mut self, width: usize)
fn with_width(&mut self, width: usize)
Sets the width.
Source§fn with_height(&mut self, height: usize)
fn with_height(&mut self, height: usize)
Sets the height.
Source§fn with_position(&mut self, position: FieldPosition)
fn with_position(&mut self, position: FieldPosition)
Sets the field position.
Auto Trait Implementations§
impl Freeze for FilePicker
impl !RefUnwindSafe for FilePicker
impl Send for FilePicker
impl Sync for FilePicker
impl Unpin for FilePicker
impl !UnwindSafe for FilePicker
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