1use anyhow::Result;
8
9use crate::client::RommClient;
10use crate::endpoints::{
11 platforms::{GetPlatform, ListPlatforms},
12 roms::{GetRom, GetRoms},
13};
14use crate::types::{Platform, Rom, RomList};
15
16pub struct PlatformService<'a> {
18 client: &'a RommClient,
19}
20
21impl<'a> PlatformService<'a> {
22 pub fn new(client: &'a RommClient) -> Self {
23 Self { client }
24 }
25
26 pub async fn list_platforms(&self) -> Result<Vec<Platform>> {
28 let platforms = self.client.call(&ListPlatforms).await?;
29 Ok(platforms)
30 }
31
32 pub async fn get_platform(&self, id: u64) -> Result<Platform> {
34 let platform = self.client.call(&GetPlatform { id }).await?;
35 Ok(platform)
36 }
37}
38
39pub struct RomService<'a> {
41 client: &'a RommClient,
42}
43
44impl<'a> RomService<'a> {
45 pub fn new(client: &'a RommClient) -> Self {
46 Self { client }
47 }
48
49 pub async fn search_roms(&self, ep: &GetRoms) -> Result<RomList> {
51 let results = self.client.call(ep).await?;
52 Ok(results)
53 }
54
55 pub async fn get_rom(&self, id: u64) -> Result<Rom> {
57 let rom = self.client.call(&GetRom { id }).await?;
58 Ok(rom)
59 }
60}