enum_str_derive/
lib.rs

1//! # enum-str-derive
2//!
3//! [![License](https://img.shields.io/github/license/enzious/enum-str-derive)](https://github.com/enzious/enum-str-derive/blob/master/LICENSE.md)
4//! [![Contributors](https://img.shields.io/github/contributors/enzious/enum-str-derive)](https://github.com/enzious/enum-str-derive/graphs/contributors)
5//! [![GitHub Repo stars](https://img.shields.io/github/stars/enzious/enum-str-derive?style=social)](https://github.com/enzious/enum-str-derive)
6//! [![crates.io](https://img.shields.io/crates/v/enum-str-derive.svg)](https://crates.io/crates/enum-str-derive)
7//!
8//! A crate to serialize/deserialize enums into/from a string.
9//!
10//! Converts enums to a string when using [serde] and [postgres].
11//!
12//! ## Documentation
13//!
14//! - [API Documentation](https://docs.rs/enum-str-derive)
15//!
16//! ## Implementation
17//!
18//! ```rust
19//! use enum_str_derive::EnumStr;
20//!
21//! #[derive(Clone, Copy, Debug, EnumStr)]
22//! pub enum ChannelTypeShortcode {
23//!   Text, // TEXT
24//!   #[enum_str(string = "w")]
25//!   Theater, // w
26//! }
27//! ```
28//!
29//! [serde]: https://crates.io/crates/serde
30//! [postgres]: https://crates.io/crates/postgres
31
32use proc_macro::TokenStream;
33
34mod enum_str;
35
36#[proc_macro_derive(EnumStr, attributes(enum_str))]
37pub fn derive_enum_str(input: TokenStream) -> TokenStream {
38  enum_str::derive_enum_str(input)
39}