Crates.io | rust-devicons |
lib.rs | rust-devicons |
version | 0.2.3 |
source | src |
created_at | 2024-09-21 13:57:40.097937 |
updated_at | 2024-09-22 21:25:43.771858 |
description | A Rust library to retrieve 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 | 1382256 |
size | 204,824 |
rust-devicons
A dead-simple and efficient Rust library inspired by vim-devicons, providing functionality to retrieve filetype glyphs (icons) for a wide range of common file formats.
Add this to your Cargo.toml
:
[dependencies]
devicons = "0.1.0"
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 your_library::{File, Theme, icon_for_file};
fn main() {
let path = Path::new("example.txt");
let file = File::new(path);
let icon = icon_for_file(&file, Some(Theme::Dark));
println!("File: {}", file.name);
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 UNLICENSE license.