romm_api/endpoints/mod.rs
1use serde_json::Value;
2
3pub mod client_tokens;
4pub mod collections;
5pub mod device;
6pub mod platforms;
7pub mod roms;
8pub mod saves;
9pub mod sync;
10pub mod system;
11pub mod tasks;
12
13/// Generic description of a RomM API endpoint.
14///
15/// Implementations of this trait define the structure and behavior of a specific
16/// API call, including its HTTP method, path, query parameters, and body.
17pub trait Endpoint {
18 /// The expected output type of this endpoint, which must be deserializable from JSON.
19 type Output;
20
21 /// Returns the HTTP method (e.g., "GET", "POST", "PUT", "DELETE").
22 fn method(&self) -> &'static str;
23
24 /// Returns the path relative to the base URL (e.g., "/api/roms").
25 fn path(&self) -> String;
26
27 /// Returns the query parameters as a list of key/value pairs.
28 /// Defaults to an empty list.
29 fn query(&self) -> Vec<(String, String)> {
30 Vec::new()
31 }
32
33 /// Returns the optional JSON request body.
34 /// Defaults to `None`.
35 fn body(&self) -> Option<Value> {
36 None
37 }
38}