Crates.io | rpa_enum |
lib.rs | rpa_enum |
version | 0.1.6 |
source | src |
created_at | 2020-05-14 01:14:56.74442 |
updated_at | 2021-06-10 21:29:22.305534 |
description | RPA Enum extension. |
homepage | |
repository | https://gitlab.com/artsoftwar3/public-libraries/rust/rpa_modules/rpa_enum |
max_upload_size | |
id | 241331 |
size | 93,236 |
This library allows the use of enums for structs on projects that are using the library rpa. Basically we allow the mapping of enums as strings on the database. So if we have for example the enum:
pub enum UserType {
PARTNER,
VISITANT,
ADMIN
}
And then we have an structure that has a field using that as a type Rpa doesn't allow us to map that enum into strings since diesel doesn't support that. With this library we can do that.
First you need to import this library like this:
[dependencies.rpa_enum]
version = "0.1.6"
Then we only need to use the derive RpaEnum to make things work, so the example above should look like this:
use rpa_enum::RpaEnum;
#[derive(RpaEnum)]
#[repr(u32)]
pub enum UserType {
PARTNER,
VISITANT,
ADMIN
}
As you can see we only need to use #[repr(u32)]
as the representation and then derive RpaEnum using the trait
from the crate like this use rpa_enum::RpaEnum;
Please visit rpa for more information on how rpa works.