pub struct RommClient { /* private fields */ }Expand description
High-level HTTP client for the ROMM API.
This type hides the details of reqwest and authentication headers
behind a small, easy-to-mock interface that all frontends can share.
Implementations§
Source§impl RommClient
impl RommClient
Sourcepub fn new(config: &Config, verbose: bool) -> Result<Self>
pub fn new(config: &Config, verbose: bool) -> Result<Self>
Construct a new client from the high-level Config.
verbose enables stderr request logging (method, path, query key names, status, timing).
This is typically done once in main and the resulting RommClient is shared
(by reference or cloning) with the chosen frontend.
pub fn verbose(&self) -> bool
Sourcepub async fn call<E>(&self, ep: &E) -> Result<E::Output>
pub async fn call<E>(&self, ep: &E) -> Result<E::Output>
Call a typed endpoint using the low-level request_json primitive.
Sourcepub async fn request_json(
&self,
method: &str,
path: &str,
query: &[(String, String)],
body: Option<Value>,
) -> Result<Value>
pub async fn request_json( &self, method: &str, path: &str, query: &[(String, String)], body: Option<Value>, ) -> Result<Value>
Low-level helper that issues an HTTP request and returns raw JSON.
Higher-level helpers (such as typed Endpoint implementations)
should prefer RommClient::call instead of using this directly.
Sourcepub async fn fetch_openapi_json(&self) -> Result<String>
pub async fn fetch_openapi_json(&self) -> Result<String>
GET the OpenAPI spec from the server. Tries openapi_spec_urls in order (HTTP/HTTPS and
/openapi.json vs /api/openapi.json). Uses resolve_openapi_root for the origin.
Sourcepub async fn download_rom<F>(
&self,
rom_id: u64,
save_path: &Path,
on_progress: F,
) -> Result<()>
pub async fn download_rom<F>( &self, rom_id: u64, save_path: &Path, on_progress: F, ) -> Result<()>
Download ROM(s) as a zip file to save_path, calling on_progress(received, total).
Uses GET /api/roms/download?rom_ids={id}&filename=… per RomM OpenAPI.
If save_path already exists on disk (e.g. from a previous interrupted
download), the client sends an HTTP Range header to resume from the
existing byte offset. The server may reply with 206 Partial Content
(resume works) or 200 OK (server doesn’t support ranges — restart
from scratch).
Trait Implementations§
Source§impl Clone for RommClient
impl Clone for RommClient
Source§fn clone(&self) -> RommClient
fn clone(&self) -> RommClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RommClient
impl !RefUnwindSafe for RommClient
impl Send for RommClient
impl Sync for RommClient
impl Unpin for RommClient
impl UnsafeUnpin for RommClient
impl !UnwindSafe for RommClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more