Skip to main content

HttpClient

Trait HttpClient 

Source
pub trait HttpClient: Send + Sync {
    // Required methods
    fn get(
        &self,
        url: &str,
        params: &[(&str, &str)],
    ) -> Pin<Box<dyn Future<Output = Result<Response, QobuzApiError>> + Send + '_>>;
    fn post_form(
        &self,
        url: &str,
        params: &[(&str, &str)],
    ) -> Pin<Box<dyn Future<Output = Result<Response, QobuzApiError>> + Send + '_>>;
    fn get_with_auth(
        &self,
        url: &str,
        token: &str,
        range: Option<&str>,
    ) -> Pin<Box<dyn Future<Output = Result<Response, QobuzApiError>> + Send + '_>>;
}
Expand description

HTTP client trait enabling deterministic testing via mock implementations.

Uses boxed futures instead of async fn to remain object-safe for dyn dispatch.

Required Methods§

Source

fn get( &self, url: &str, params: &[(&str, &str)], ) -> Pin<Box<dyn Future<Output = Result<Response, QobuzApiError>> + Send + '_>>

Sends a GET request with query parameters.

§Arguments
  • url - Full URL to send the request to
  • params - Key-value query parameter pairs
§Returns

The HTTP response.

Source

fn post_form( &self, url: &str, params: &[(&str, &str)], ) -> Pin<Box<dyn Future<Output = Result<Response, QobuzApiError>> + Send + '_>>

Sends a POST request with form parameters.

§Arguments
  • url - Full URL to send the request to
  • params - Key-value form parameter pairs
§Returns

The HTTP response.

Source

fn get_with_auth( &self, url: &str, token: &str, range: Option<&str>, ) -> Pin<Box<dyn Future<Output = Result<Response, QobuzApiError>> + Send + '_>>

Sends an authenticated GET request with optional Range header.

§Arguments
  • url - Full URL to send the request to
  • token - Bearer authentication token
  • range - Optional Range header value (e.g., "bytes=1024-")
§Returns

The HTTP response.

Implementors§