| Crates.io | duat-filetype |
| lib.rs | duat-filetype |
| version | 0.3.0 |
| created_at | 2025-06-16 06:04:55.406606+00 |
| updated_at | 2025-08-20 13:37:51.697234+00 |
| description | Filetype detection for the File widget from Duat |
| homepage | https://github.com/AhoyISki/duat-filetype |
| repository | |
| max_upload_size | |
| id | 1713927 |
| size | 150,105 |
Filetypes for the Duat text editor
This Plugin is included by default, as it is considered a core
utility of duat. It adds the two following traits:
FileType: This trait grants the filetype
method, which lets you access the filetype directly. Its
implementors are the File widget, String and &str
and PathBuf and Path.PassFileType: This trait also has a
filetype method, but it requires a
Pass, bypassing the need to, for example, read a
Handle<File<Ui>, Ui>. Its implementors are
RwData<File<Ui>>, Handle<File<Ui>, Ui>,
FileHandle<Ui> and FileBuilder<Ui>, from the
OnFileOpen hook.Both of these traits are included by default in Duat’s
prelude, but if you want to use them in a plugin, first, add
duat-filetype to the dependencies:
cargo add duat-filetype
Or, for latest git version:
cargo add --git https://github.com/AhoyISki/duat-filetype
Then, just use it in the file:
use duat_filetype::FileType;
fn is_toml(file_name: &str) -> bool {
file_name.filetype() == Some("toml")
}