1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
use crate::model::artist::Artist; use crate::model::event::Event; use crate::model::label::Label; use crate::model::place::Place; use crate::model::recording::Recording; use crate::model::release::Release; use crate::model::release_group::ReleaseGroup; use crate::model::work::Work; #[derive(Debug, Serialize, PartialEq, Clone)] #[serde(rename_all(deserialize = "kebab-case"))] pub struct BrowseResult<T> { pub count: i32, pub offset: i32, pub entities: Vec<T>, } pub trait Browsable { const COUNT_FIELD: &'static str; const OFFSET_FIELD: &'static str; const ENTITIES_FIELD: &'static str; } impl Browsable for Artist { const COUNT_FIELD: &'static str = "artist-count"; const OFFSET_FIELD: &'static str = "artist-offset"; const ENTITIES_FIELD: &'static str = "artists"; } impl Browsable for Event { const COUNT_FIELD: &'static str = "event-count"; const OFFSET_FIELD: &'static str = "event-offset"; const ENTITIES_FIELD: &'static str = "events"; } impl Browsable for Label { const COUNT_FIELD: &'static str = "label-count"; const OFFSET_FIELD: &'static str = "label-offset"; const ENTITIES_FIELD: &'static str = "labels"; } impl Browsable for Place { const COUNT_FIELD: &'static str = "place-count"; const OFFSET_FIELD: &'static str = "place-offset"; const ENTITIES_FIELD: &'static str = "places"; } impl Browsable for Recording { const COUNT_FIELD: &'static str = "recording-count"; const OFFSET_FIELD: &'static str = "recording-offset"; const ENTITIES_FIELD: &'static str = "recordings"; } impl Browsable for Release { const COUNT_FIELD: &'static str = "release-count"; const OFFSET_FIELD: &'static str = "release-offset"; const ENTITIES_FIELD: &'static str = "releases"; } impl Browsable for ReleaseGroup { const COUNT_FIELD: &'static str = "release-group-count"; const OFFSET_FIELD: &'static str = "release-group-offset"; const ENTITIES_FIELD: &'static str = "release-groups"; } impl Browsable for Work { const COUNT_FIELD: &'static str = "work-count"; const OFFSET_FIELD: &'static str = "work-offset"; const ENTITIES_FIELD: &'static str = "works"; }