deribit_http/model/response/
api_response.rs

1/******************************************************************************
2   Author: Joaquín Béjar García
3   Email: jb@taunais.com
4   Date: 15/9/25
5******************************************************************************/
6use crate::model::types::ApiError;
7use pretty_simple_display::{DebugPretty, DisplaySimple};
8use serde::{Deserialize, Serialize};
9use serde_with::skip_serializing_none;
10use std::collections::HashMap;
11
12/// HTTP response structure
13#[skip_serializing_none]
14#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
15pub struct HttpResponse {
16    /// HTTP status code
17    pub status: u16,
18    /// Response headers as key-value pairs
19    pub headers: HashMap<String, String>,
20    /// Response body content
21    pub body: String,
22}
23
24/// Generic API response wrapper
25#[skip_serializing_none]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct ApiResponse<T> {
28    /// Successful result data
29    pub result: Option<T>,
30    /// Error information if request failed
31    pub error: Option<ApiError>,
32    /// Request ID for tracking
33    pub id: Option<u64>,
34    /// Server processing start time in microseconds
35    #[serde(rename = "usIn")]
36    pub us_in: Option<u64>,
37    /// JSON-RPC version (typically "2.0")
38    pub jsonrpc: Option<String>,
39    /// Server processing end time in microseconds
40    #[serde(rename = "usOut")]
41    pub us_out: Option<u64>,
42    /// Processing time difference in microseconds
43    #[serde(rename = "usDiff")]
44    pub us_diff: Option<u64>,
45    /// Whether this is a testnet response
46    pub testnet: Option<bool>,
47}