https://github.com/enzious/enum-str-derive
A crate to serialize/deserialize enums into/from a string.
https://github.com/enzious/enum-str-derive
Last synced: about 1 month ago
JSON representation
A crate to serialize/deserialize enums into/from a string.
- Host: GitHub
- URL: https://github.com/enzious/enum-str-derive
- Owner: enzious
- License: mit
- Created: 2023-04-25T02:18:40.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-26T23:37:36.000Z (about 3 years ago)
- Last Synced: 2025-03-10T09:51:43.002Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# enum-str-derive
[](https://github.com/enzious/enum-str-derive/blob/master/LICENSE.md)
[](https://github.com/enzious/enum-str-derive/graphs/contributors)
[](https://github.com/enzious/enum-str-derive)
[](https://crates.io/crates/enum-str-derive)
A crate to serialize/deserialize enums into/from a string.
Converts enums to a string when using [serde] and [postgres].
## Documentation
- [API Documentation](https://docs.rs/enum-str-derive)
## Implementation
```rust
#[derive(Clone, Copy, Debug, EnumStr)]
pub enum ChannelTypeShortcode {
Text, // TEXT
#[enum_str(string = "w")]
Theater, // w
}
```
[serde]: https://crates.io/crates/serde
[postgres]: https://crates.io/crates/postgres