Skip to main content

romm_cli/endpoints/
mod.rs

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