example of using enum to be more explicit about data
This commit is contained in:
parent
586db06b3a
commit
adc8bc8c04
2 changed files with 34 additions and 1 deletions
|
@ -62,6 +62,18 @@ mod image_model {
|
|||
TitleRole,
|
||||
}
|
||||
|
||||
impl FromStr for Role {
|
||||
type Err = ();
|
||||
fn from_str(input: &str) -> Result<Role, Self::Err> {
|
||||
match input {
|
||||
"id" => Ok(Role::IdRole),
|
||||
"title" => Ok(Role::TitleRole),
|
||||
"path" => Ok(Role::PathRole),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// use crate::entities::{images, prelude::Images};
|
||||
// use sea_orm::{ConnectionTrait, Database, DbBackend, DbErr, Statement, ActiveValue};
|
||||
impl qobject::ImageModel {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue