Skip to main content

FilePicker

Struct FilePicker 

Source
pub struct FilePicker {
Show 13 fields pub root: Option<PathBuf>, pub path: Option<PathBuf>, pub allowed_types: Vec<String>, pub key_map: KeyMap, pub show_permissions: bool, pub show_size: bool, pub show_hidden: bool, pub dir_allowed: bool, pub file_allowed: bool, pub height: usize, pub auto_height: bool, pub cursor_char: String, pub styles: Styles, /* private fields */
}
Expand description

File picker model for browsing and selecting files.

Fields§

§root: Option<PathBuf>

Root directory (jail) for navigation.

§path: Option<PathBuf>

Currently selected path (after selection).

§allowed_types: Vec<String>

Allowed file extensions (empty = all allowed).

§key_map: KeyMap

Key bindings.

§show_permissions: bool

Whether to show permissions.

§show_size: bool

Whether to show file sizes.

§show_hidden: bool

Whether to show hidden files.

§dir_allowed: bool

Whether directories can be selected.

§file_allowed: bool

Whether files can be selected.

§height: usize

Height of the picker in rows.

§auto_height: bool

Whether to auto-adjust height based on window size.

§cursor_char: String

Cursor character.

§styles: Styles

Styles.

Implementations§

Source§

impl FilePicker

Source

pub fn new() -> Self

Creates a new file picker with default settings.

Source

pub fn id(&self) -> u64

Returns the unique ID of this file picker.

Source

pub fn current_directory(&self) -> &Path

Returns the current directory.

Source

pub fn set_root(&mut self, root: impl AsRef<Path>)

Sets the root directory (jail). Navigation above this directory will be blocked.

Source

pub fn set_current_directory(&mut self, path: impl AsRef<Path>)

Sets the current directory.

Source

pub fn set_height(&mut self, height: usize)

Sets the height of the file picker.

Source

pub fn set_allowed_types(&mut self, types: Vec<String>)

Sets the allowed file types.

Source

pub fn selected_path(&self) -> Option<&Path>

Returns the selected file path, if any.

Source

pub fn highlighted_entry(&self) -> Option<&DirEntry>

Returns the currently highlighted entry, if any.

Source

pub fn init(&self) -> Option<Cmd>

Initializes the file picker and returns a command to read the directory.

Source

pub fn did_select_file(&self, msg: &Message) -> Option<PathBuf>

Checks if this message indicates a file was selected.

Source

pub fn did_select_disabled_file(&self, msg: &Message) -> Option<PathBuf>

Checks if this message indicates a disabled file was selected.

Source

pub fn update(&mut self, msg: Message) -> Option<Cmd>

Updates the file picker based on messages.

Source

pub fn view(&self) -> String

Renders the file picker.

Trait Implementations§

Source§

impl Clone for FilePicker

Source§

fn clone(&self) -> FilePicker

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FilePicker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FilePicker

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Model for FilePicker

Source§

fn init(&self) -> Option<Cmd>

Initialize the file picker by reading the current directory.

Source§

fn update(&mut self, msg: Message) -> Option<Cmd>

Update the file picker state based on incoming messages.

Source§

fn view(&self) -> String

Render the file picker.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more