Skip to main content

RommClient

Struct RommClient 

Source
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 interface that all frontends can share.

Implementations§

Source§

impl RommClient

Source

pub async fn download_rom<F>( &self, rom_id: u64, save_path: &Path, on_progress: F, ) -> Result<(), DownloadError>
where F: FnMut(u64, u64) + Send,

Downloads a ROM (or multiple ROMs as a zip) to the specified path.

Source

pub async fn download_rom_with_cancel<F, C>( &self, rom_id: u64, save_path: &Path, is_cancelled: C, on_progress: &mut F, ) -> Result<(), DownloadError>
where F: FnMut(u64, u64) + Send, C: FnMut(u64, u64) -> bool + Send,

Source

pub async fn download_url_with_cancel<F, C>( &self, url: &str, save_path: &Path, is_cancelled: C, on_progress: &mut F, ) -> Result<(), DownloadError>
where F: FnMut(u64, u64) + Send, C: FnMut(u64, u64) -> bool + Send,

Downloads an arbitrary URL to save_path, supporting auth headers and resume.

Source

pub async fn download_url_with_query_with_cancel<F, C>( &self, url: &str, query: &[(String, String)], save_path: &Path, is_cancelled: C, on_progress: &mut F, ) -> Result<(), DownloadError>
where F: FnMut(u64, u64) + Send, C: FnMut(u64, u64) -> bool + Send,

Downloads an arbitrary URL and query to save_path, supporting auth headers and resume.

Source§

impl RommClient

Source

pub async fn rom_server_version_from_heartbeat(&self) -> Option<String>

RomM application version from GET /api/heartbeat (SYSTEM.VERSION), if the endpoint succeeds.

Source

pub async fn fetch_openapi_json(&self) -> Result<String, ApiError>

GET the OpenAPI spec from the server.

Source§

impl RommClient

Source

pub async fn call<E>(&self, ep: &E) -> Result<E::Output, ApiError>

Executes a typed Endpoint and returns its deserialized output.

Source

pub async fn request_json( &self, method: &str, path: &str, query: &[(String, String)], body: Option<Value>, ) -> Result<Value, ApiError>

Low-level helper that issues an HTTP request and returns a raw JSON Value.

Source

pub async fn request_json_unauthenticated( &self, method: &str, path: &str, query: &[(String, String)], body: Option<Value>, ) -> Result<Value, ApiError>

Source

pub async fn get_bytes( &self, path: &str, query: &[(String, String)], ) -> Result<Vec<u8>, ApiError>

Authenticated GET returning raw bytes.

Source

pub async fn post_bytes( &self, path: &str, query: &[(String, String)], json_body: Option<Value>, ) -> Result<Vec<u8>, ApiError>

POST returning raw bytes.

Source§

impl RommClient

Source

pub async fn run_task( &self, task_name: &str, kwargs: Option<Value>, ) -> Result<Value, ApiError>

Triggers a server-side task by name (e.g., "scan_library").

Source

pub async fn get_task_status(&self, task_id: &str) -> Result<Value, ApiError>

Polls the status of a running task by its ID.

Source

pub async fn run_all_tasks(&self) -> Result<Value, ApiError>

Enqueues all runnable tasks on the server.

Source

pub async fn list_tasks(&self) -> Result<Value, ApiError>

Lists all recent and active tasks.

Source

pub async fn get_tasks_queue_status(&self) -> Result<Value, ApiError>

Returns the current status of the task queue.

Source§

impl RommClient

Source

pub async fn upload_rom<F>( &self, platform_id: u64, file_path: &Path, on_progress: F, ) -> Result<(), ApiError>
where F: FnMut(u64, u64) + Send,

Uploads a ROM file to the server using the RomM chunked upload API.

Source

pub async fn upload_save_file( &self, rom_id: u64, emulator: Option<&str>, file_path: &Path, ) -> Result<Value, ApiError>

Uploads a game save file to the server.

Source

pub async fn upload_save_file_with_options( &self, rom_id: u64, file_path: &Path, options: &SaveUploadOptions<'_>, ) -> Result<Value, ApiError>

Uploads a game save file with sync-specific options.

Source

pub async fn download_save_content( &self, save_id: u64, device_id: Option<&str>, session_id: Option<u64>, ) -> Result<Vec<u8>, ApiError>

Downloads save content from GET /api/saves/{id}/content.

Source

pub async fn upload_state_file( &self, rom_id: u64, emulator: Option<&str>, file_path: &Path, ) -> Result<Value, ApiError>

POST /api/states with multipart field stateFile.

Source

pub async fn upload_screenshot_file( &self, rom_id: u64, file_path: &Path, ) -> Result<Value, ApiError>

POST /api/screenshots with multipart field screenshotFile.

Source

pub async fn upload_firmware_file( &self, platform_id: u64, file_path: &Path, ) -> Result<Value, ApiError>

POST /api/firmware?platform_id= with multipart files.

Source

pub async fn upload_rom_manual( &self, rom_id: u64, file_path: &Path, ) -> Result<Value, ApiError>

POST /api/roms/{id}/manuals — raw file body with x-upload-filename header.

Source§

impl RommClient

Source

pub fn new(config: &Config, verbose: bool) -> Result<Self, ApiError>

Construct a new client from the high-level Config.

Source

pub fn verbose(&self) -> bool

Returns true if verbose logging is enabled.

Trait Implementations§

Source§

impl Clone for RommClient

Source§

fn clone(&self) -> RommClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more