#enums #mysql

macro mysql_enum_derive

Library for mysql enum

3 releases

0.1.2 May 17, 2019
0.1.1 May 7, 2019
0.1.0 May 7, 2019

#123 in #enum

Download history 14/week @ 2024-02-23 10/week @ 2024-03-01 45/week @ 2024-03-29 16/week @ 2024-04-05

61 downloads per month
Used in mysql_enum



mysql enum derive


This crate provides a derive that adds boilerplate code to convert a MySQL row value into an enum.
This crate does not provide functionality to convert an enum into a string or vice versa. In order to provide to_string() and String::parse(..) functions you must include another crate. However there are many crates that can do this, choose one!


To use your enum with MySQL with the help of strum, add this to your Cargo.toml:

mysql_enum ="0.1"
strum = "0.14"
strum_macros = "0.14"

Now annotate your enum.

use mysql_enum::MysqlEnum;
use strum_macros::{Display, EnumString};

#[derive(PartialEq, EnumString, Display, MysqlEnum)]
pub enum UserRole {

For a complete example check out the test function.


mysql_enum is distributed under the terms of both the MIT license and the Apache License (Version 2.0).


~48K SLoC