mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
Rewrite to rust init
This commit is contained in:
44
src/serializers/genre.rs
Normal file
44
src/serializers/genre.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use crate::prisma::genre;
|
||||
|
||||
use super::source::Source;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct Genre {
|
||||
pub id: i32,
|
||||
pub source: Source,
|
||||
pub remote_id: i32,
|
||||
pub code: String,
|
||||
pub description: String,
|
||||
pub meta: String
|
||||
}
|
||||
|
||||
impl From<genre::Data> for Genre {
|
||||
fn from(val: genre::Data) -> Self {
|
||||
let genre::Data {
|
||||
id,
|
||||
remote_id,
|
||||
code,
|
||||
description,
|
||||
meta,
|
||||
source,
|
||||
..
|
||||
} = val;
|
||||
|
||||
Genre {
|
||||
id,
|
||||
remote_id,
|
||||
code,
|
||||
description,
|
||||
meta,
|
||||
source: source.unwrap().as_ref().clone().into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct GenreFilter {
|
||||
pub meta: Option<String>,
|
||||
}
|
||||
Reference in New Issue
Block a user