Struct PickRequest
pub struct PickRequest { /* private fields */ }Expand description
A portal file-chooser request, built up and then send
on a worker thread.
The per-app delta between what used to be nine hand-written copies of this module is exactly what this struct captures: a title, an accept label, a filter set, and a worker-thread name.
Implementations§
§impl PickRequest
impl PickRequest
pub fn open(title: &str, accept_label: &str) -> PickRequest
pub fn open(title: &str, accept_label: &str) -> PickRequest
A single-file open chooser.
pub fn open_multiple(title: &str, accept_label: &str) -> PickRequest
pub fn open_multiple(title: &str, accept_label: &str) -> PickRequest
A multi-select open chooser: the user may pick arbitrarily many files at once and every local one comes back.
pub fn directory(title: &str, accept_label: &str) -> PickRequest
pub fn directory(title: &str, accept_label: &str) -> PickRequest
Pick one existing folder. Directory authority still comes from the desktop portal; callers should not invent a path or build a private filesystem browser.
pub fn save(
title: &str,
accept_label: &str,
suggested_name: &str,
) -> PickRequest
pub fn save( title: &str, accept_label: &str, suggested_name: &str, ) -> PickRequest
A Save chooser, seeding the filename field with suggested_name.
pub fn max_contents_bytes(self, limit: usize) -> PickRequest
pub fn max_contents_bytes(self, limit: usize) -> PickRequest
Bound the total contents returned across all chosen files. Oversized
selections fail without reading their full contents into memory.
Applies to send_contents, not path or descriptor requests. With no
override, the host’s existing contents policy applies.
pub fn contents_byte_limit(&self) -> Option<usize>
pub fn contents_byte_limit(&self) -> Option<usize>
The requested aggregate contents budget, when explicitly bounded.
pub fn thread_name(self, name: &str) -> PickRequest
pub fn thread_name(self, name: &str) -> PickRequest
Name the worker thread, so a stuck picker is identifiable in a
backtrace or top -H. Pickers that run on a dedicated thread (the
Windows dialogs) use it; the Unix portal’s D-Bus requests run on the
shared app runtime instead.
pub fn filter(self, f: FileFilter) -> PickRequest
pub fn filter(self, f: FileFilter) -> PickRequest
Add a file-type filter. Order is the dropdown order; the first is the default.
pub fn all_files(self) -> PickRequest
pub fn all_files(self) -> PickRequest
Append the “All files” escape hatch.
pub fn title(&self) -> &str
pub fn is_multiple(&self) -> bool
pub fn filter_names(&self) -> Vec<&str>
pub fn filter_names(&self) -> Vec<&str>
The filter dropdown labels, in order. Lets an app assert on the chooser it configured without opening one.
pub fn suggested_name(&self) -> Option<&str>
pub fn suggested_name(&self) -> Option<&str>
The filename this request seeds a Save dialog with, if it is one.
pub fn accept_label(&self) -> &str
pub fn accept_label(&self) -> &str
The chooser’s accept-button label.
pub fn filters(&self) -> &[FileFilter]
pub fn filters(&self) -> &[FileFilter]
The file-type filters, in dropdown order.
pub fn is_directory(&self) -> bool
pub fn is_directory(&self) -> bool
Whether this chooses a folder rather than files.
pub fn worker_name(&self) -> &str
pub fn worker_name(&self) -> &str
The name of the worker thread a native picker runs on, when it runs
on one (see Self::thread_name).
pub fn send(self) -> Receiver<PortalOutcome>
pub fn send(self) -> Receiver<PortalOutcome>
Hand the request to the current host’s crate::FilePicker.
The UI thread is never blocked: the native picker runs the D-Bus
round-trip and the host dialog entirely on a worker. A multi-select
request should go through send_multiple
instead, so every pick is delivered.
pub fn send_scoped(self, scope: impl EffectGate) -> Receiver<PortalOutcome>
pub fn send_scoped(self, scope: impl EffectGate) -> Receiver<PortalOutcome>
Retain the original admitted caller through the actual chooser. The caller is rechecked on a worker immediately before the host picker runs; an expired caller never reaches the chooser effect.
pub fn send_open_file(self) -> Receiver<OpenFileOutcome>
pub fn send_open_file(self) -> Receiver<OpenFileOutcome>
Open one selected regular file on the portal worker and deliver its descriptor to the UI. This is intentionally a separate outcome path so normal path-based open/save callers retain their existing API.
This is valid only for a single-file Open request. Calling it for Save or multi-select requests reports a normal failed outcome.
pub fn send_save_file(self) -> Receiver<OpenFileOutcome>
pub fn send_save_file(self) -> Receiver<OpenFileOutcome>
Save counterpart of send_open_file: the
destination the user chose, created and open for writing. Android’s
chooser creates a document with no path the app may write, so a Save
there must come through here; hosts that answer Save with a path
refuse it. Valid only for a Save request.
pub fn send_multiple(self) -> Receiver<MultiOutcome>
pub fn send_multiple(self) -> Receiver<MultiOutcome>
Multi-select counterpart of send.
pub fn send_contents(self) -> Receiver<ContentsOutcome>
pub fn send_contents(self) -> Receiver<ContentsOutcome>
Deliver the chosen files’ contents instead of paths, for callers that only read what the user picked. Works where no local path exists (a browser page). Open requests only; multi-select delivers every file.
pub fn send_save_contents(self, bytes: Vec<u8>) -> Receiver<SaveOutcome>
pub fn send_save_contents(self, bytes: Vec<u8>) -> Receiver<SaveOutcome>
Save bytes where the user chooses. Save requests only. A browser
page downloads them under the suggested name.
Trait Implementations§
§impl Clone for PickRequest
impl Clone for PickRequest
§fn clone(&self) -> PickRequest
fn clone(&self) -> PickRequest
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 PickRequest
impl RefUnwindSafe for PickRequest
impl Send for PickRequest
impl Sync for PickRequest
impl Unpin for PickRequest
impl UnsafeUnpin for PickRequest
impl UnwindSafe for PickRequest
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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