Crates.io | devicons |
lib.rs | devicons |
version | |
source | src |
created_at | 2024-09-09 12:33:12.857056 |
updated_at | 2024-10-15 21:41:59.102132 |
description | A Rust library that provides filetype glyphs (icons) for a wide range of common file formats. |
homepage | https://github.com/alexpasmantier/rust-devicons |
repository | https://github.com/alexpasmantier/rust-devicons |
max_upload_size | |
id | 1369214 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
rust-devicons
A Rust library inspired by vim-devicons, that provides filetype glyphs (icons) for a wide range of common file formats.
cargo add devicons
NOTE: you'll need to use a NerdFont to properly display the icons.
Hereβs a simple example of how to use devicons
to retrieve a file icon with the dark theme:
use std::path::Path;
use devicons::{File, Theme, icon_for_file, FileIcon};
fn main() {
// getting the icon from a path with a specified theme
let path = Path::new("Cargo.toml");
let icon = icon_for_file(path, Some(Theme::Dark));
// getting the icon from a string with a specified theme
let icon = icon_for_file("Cargo.toml", Some(Theme::Dark));
// getting the icon from a path with the default theme
let icon = FileIcon::from(path);
// directly getting an icon from a filename
let icon = FileIcon::from("Cargo.toml");
println!("File: {}", path.to_string_lossy());
println!("Icon: {}", icon.icon);
println!("Color: {}", icon.color);
}
You can find more usage examples in the examples
directory. To run them, use:
cargo run --example <example_name>
This project is licensed under the Apache 2.0 License.