Struct druid_shell::FileSpec
source · pub struct FileSpec {
pub name: &'static str,
pub extensions: &'static [&'static str],
}
Expand description
A description of a filetype, for specifying allowed types in a file dialog.
Windows
Each instance of this type is converted to a COMDLG_FILTERSPEC
struct.
macOS
These file types also apply to directories to define them as packages.
Fields§
§name: &'static str
A human readable name, describing this filetype.
This is used in the Windows file dialog, where the user can select from a dropdown the type of file they would like to choose.
This should not include the file extensions; they will be added automatically. For instance, if we are describing Word documents, the name would be “Word Document”, and the displayed string would be “Word Document (*.doc)”.
extensions: &'static [&'static str]
The file extensions used by this file type.
This should not include the leading ‘.’.
Implementations§
source§impl FileSpec
impl FileSpec
pub const TEXT: FileSpec = _
pub const JPG: FileSpec = _
pub const GIF: FileSpec = _
pub const PNG: FileSpec = _
pub const PDF: FileSpec = _
pub const HTML: FileSpec = _
sourcepub const fn new(name: &'static str, extensions: &'static [&'static str]) -> Self
pub const fn new(name: &'static str, extensions: &'static [&'static str]) -> Self
Create a new FileSpec
.
Examples found in repository?
examples/shello.rs (line 55)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
fn command(&mut self, id: u32) {
match id {
0x100 => {
self.handle.close();
Application::global().quit()
}
0x101 => {
let options = FileDialogOptions::new().show_hidden().allowed_types(vec![
FileSpec::new("Rust Files", &["rs", "toml"]),
FileSpec::TEXT,
FileSpec::JPG,
]);
self.handle.open_file(options);
}
0x102 => {
let options = FileDialogOptions::new().show_hidden().allowed_types(vec![
FileSpec::new("Rust Files", &["rs", "toml"]),
FileSpec::TEXT,
FileSpec::JPG,
]);
self.handle.save_as(options);
}
_ => println!("unexpected id {id}"),
}
}
Trait Implementations§
source§impl PartialEq<FileSpec> for FileSpec
impl PartialEq<FileSpec> for FileSpec
impl Copy for FileSpec
impl Eq for FileSpec
impl StructuralEq for FileSpec
impl StructuralPartialEq for FileSpec
Auto Trait Implementations§
impl RefUnwindSafe for FileSpec
impl Send for FileSpec
impl Sync for FileSpec
impl Unpin for FileSpec
impl UnwindSafe for FileSpec
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> RoundFrom<T> for T
impl<T> RoundFrom<T> for T
§fn round_from(x: T) -> T
fn round_from(x: T) -> T
Performs the conversion.
§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,
§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.