extensions_rs/lib.rs
1//! extensions-rs
2//!
3//! [](https://github.com/travisbaars/extensions-rs/actions)
4//! [](https://crates.io/crates/extensions-rs)
5//! [](https://docs.rs/extensions-rs)
6//!
7//! A collection of file extension types in Rust.
8//!
9//! The idea behind this crate is to give a simple way of handling file extension types.
10//!
11//! ## Installation
12//!
13//! Add `extensions-rs` to your project's `Cargo.toml` file:
14//!
15//! ```toml
16//! [dependencies]
17//! extensions-rs = "0.2.1"
18//! ```
19//!
20//! Or use `cargo add`:
21//!
22//! ```bash
23//! cargo add extensions-rs
24//! ```
25//!
26//! ## Examples
27//!
28//! #### Conversion from `Extension` to `str`:
29//!
30//! ```rust
31//! use extensions_rs::Extension;
32//! use extensions_rs::ext::Image;
33//!
34//! assert_eq!("png", Extension::to_str(Extension::Image(Image::ExtPNG)));
35//! ```
36//!
37//! #### Simple conversion, `&str` to `Image` type:
38//!
39//! ```rust
40//! use extensions_rs::ext::Image;
41//!
42//! assert_eq!(Image::ExtJPG, Image::from("jpg"));
43//! ```
44//!
45//! #### Validate extension:
46//!
47//! ```
48//! use extensions_rs::utils::Validate;
49//!
50//! # tokio_test::block_on(async {
51//! assert_eq!(true, Validate::check_str("jpg").await);
52//! # })
53//! ```
54
55pub(crate) mod types;
56pub(crate) mod validation;
57
58pub use crate::types::{ExtType, Extension};
59
60pub mod ext {
61 pub use crate::types::image::Image;
62}
63
64pub mod utils {
65 pub use crate::validation::Validate;
66}