Skip to main content

FilePicker

Trait FilePicker 

Source
pub trait FilePicker {
    // Required methods
    fn pick_file(
        &self,
        options: FilePickerOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Rc<dyn PickedEntry>>, FilePickerError>>>>;
    fn pick_folder(
        &self,
        options: FilePickerOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Rc<dyn PickedEntry>>, FilePickerError>>>>;

    // Provided methods
    fn pick_folder_streaming(
        &self,
        options: FilePickerOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Rc<dyn FolderStream>>, FilePickerError>>>> { ... }
    fn take_resumed_picks(&self) -> Vec<ResumedPick> { ... }
}
Expand description

Re-export framework services (HTTP, URI, etc.) from the dedicated services crate. Presents native file and folder pickers.

Required Methods§

Source

fn pick_file( &self, options: FilePickerOptions, ) -> Pin<Box<dyn Future<Output = Result<Option<Rc<dyn PickedEntry>>, FilePickerError>>>>

Presents a single-file picker. Resolves to None if cancelled.

Source

fn pick_folder( &self, options: FilePickerOptions, ) -> Pin<Box<dyn Future<Output = Result<Option<Rc<dyn PickedEntry>>, FilePickerError>>>>

Presents a folder/tree picker. Resolves to None if cancelled.

Provided Methods§

Source

fn pick_folder_streaming( &self, options: FilePickerOptions, ) -> Pin<Box<dyn Future<Output = Result<Option<Rc<dyn FolderStream>>, FilePickerError>>>>

Presents a folder picker and streams the tree’s files as they are discovered (see FolderStream).

The default walks the picked folder eagerly via pick_folder and yields every file at once; backends served by a slow provider (Android’s Storage Access Framework) override this to stream during the walk. Resolves to None if cancelled.

Source

fn take_resumed_picks(&self) -> Vec<ResumedPick>

Reclaims selections whose results arrived after the requesting composition was torn down. On Android the activity (and the native app) can be destroyed and recreated while the SAF picker is in front, so a pick in flight at that moment would otherwise be lost; the app drains this on startup to recover it. Returns the orphaned selections, usually none. Backends that never lose a result (desktop, web, iOS, the fallbacks) keep the default empty implementation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§