Crate extensions_rs

Source
Expand description

extensions-rs

GitHub Actions Workflow Status Crates.io Version docs.rs

A collection of file extension types in Rust.

The idea behind this crate is to give a simple way of handling file extension types.

§Installation

Add extensions-rs to your project’s Cargo.toml file:

[dependencies]
extensions-rs = "0.2.1"

Or use cargo add:

cargo add extensions-rs

§Examples

§Conversion from Extension to str:
use extensions_rs::Extension;
use extensions_rs::ext::Image;

assert_eq!("png", Extension::to_str(Extension::Image(Image::ExtPNG)));
§Simple conversion, &str to Image type:
use extensions_rs::ext::Image;

assert_eq!(Image::ExtJPG, Image::from("jpg"));
§Validate extension:
use extensions_rs::utils::Validate;

assert_eq!(true, Validate::check_str("jpg").await);

Modules§

ext
utils

Enums§

ExtType
Extension