mangadex_api_schema_rust/v5/
manga_recommendation.rs

1use mangadex_api_types::RelationshipType;
2use serde::Deserialize;
3use uuid::Uuid;
4
5use crate::{
6    TypedAttributes,
7    v5::{MangaRecommendationCollection, MangaRecommendationObject},
8};
9
10/// Manga Recommendation attributes
11///
12/// Used only at `GET /manga/{id}/recommendation`
13#[derive(Debug, Deserialize, Clone, Default)]
14#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
15#[serde(rename_all = "camelCase")]
16#[cfg_attr(feature = "specta", derive(specta::Type))]
17#[non_exhaustive]
18pub struct MangaRecommendationAttributes {
19    /// The actual score
20    ///
21    /// Often a value between 0.0 to 1.0
22    pub score: f32,
23}
24
25impl TypedAttributes for MangaRecommendationAttributes {
26    const TYPE_: mangadex_api_types::RelationshipType = RelationshipType::MangaRecommendation;
27}
28
29impl MangaRecommendationObject {
30    pub fn titles(&self) -> Vec<Uuid> {
31        self.find_relationships(RelationshipType::Manga)
32            .into_iter()
33            .map(|r| r.id)
34            .collect()
35    }
36}
37
38impl MangaRecommendationCollection {
39    // pub fn title_scored()
40}