From 1cc32c35edaf6b8c2f468c22ccf61f3f07027e81 Mon Sep 17 00:00:00 2001 From: A Farzat Date: Mon, 2 Mar 2026 14:20:23 +0300 Subject: Refactor away SearchResponse model Its functionality is covered by Paginated. The fetch_metadata function was also replaced by the more generic fetch_all_pages. Given that we are searching by the isbn, we should presumably get only 1 result, so only one call will be made even when fetch_all_pages is used. This behaviour is not documented though, so switching to the metadata endpoint in the future is recommended. --- src/models.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'src/models.rs') diff --git a/src/models.rs b/src/models.rs index 174b983..843744d 100644 --- a/src/models.rs +++ b/src/models.rs @@ -1,12 +1,13 @@ use serde::Deserialize; -// --- Models for the Search API --- - -#[derive(Debug, Deserialize)] -pub struct SearchResponse { - pub results: Vec, +/// Generic Model for paginated API. +#[derive(Debug, serde::Deserialize)] +pub struct Paginated { + pub next: Option, + pub results: Vec, } +/// Model for the Search API. #[derive(Debug, Deserialize)] pub struct SearchResult { pub title: String, @@ -15,8 +16,7 @@ pub struct SearchResult { pub cover_url: String, } -// --- Models for the EPUB API --- - +/// Model for the EPUB API. #[derive(Debug, Deserialize)] pub struct EpubResponse { pub publication_date: String, @@ -24,14 +24,6 @@ pub struct EpubResponse { pub files: String, // This is a URL to the resource files } -// --- Generic Model for paginated API --- - -#[derive(Debug, serde::Deserialize)] -pub struct Paginated { - pub next: Option, - pub results: Vec, -} - /// Model for chapters API. #[derive(Debug, Deserialize)] pub struct Chapter { -- cgit v1.2.3-70-g09d2