-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: [#501] decouple database struct from API response for Category
- Loading branch information
1 parent
f6890cd
commit 09e1620
Showing
8 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::databases::database::Category as DatabaseCategory; | ||
|
||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)] | ||
pub struct Category { | ||
pub id: i64, | ||
// Deprecated. Use `id`. | ||
pub category_id: i64, | ||
pub name: String, | ||
pub num_torrents: i64, | ||
} | ||
|
||
#[allow(clippy::module_name_repetitions)] | ||
pub type CategoryId = i64; | ||
|
||
impl From<DatabaseCategory> for Category { | ||
fn from(db_category: DatabaseCategory) -> Self { | ||
Category { | ||
id: db_category.category_id, | ||
category_id: db_category.category_id, | ||
name: db_category.name, | ||
num_torrents: db_category.num_torrents, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters