Skip to main content

dedust_api_client/v2/
response.rs

1//! Raw DeDust API v2 response variants.
2//!
3//! Names and fields intentionally mirror the upstream wire contract.
4#![allow(missing_docs, reason = "raw response models mirror the upstream API contract")]
5
6use crate::v2::types::*;
7use derive_more::From;
8use serde_derive::Deserialize;
9
10#[macro_export]
11macro_rules! unwrap_response {
12    ($variant:ident, $result:expr) => {
13        match $result {
14            $crate::v2::V2Response::$variant(inner) => Ok(inner),
15            other => Err($crate::api_clients_core::ApiClientsError::UnexpectedResponse(format!(
16                "ApiClientError: expected {}, but got {:?}",
17                stringify!($variant),
18                other
19            ))),
20        }
21    };
22}
23
24#[derive(Deserialize, Debug, Clone, From)]
25#[non_exhaustive]
26pub enum V2Response {
27    Assets(Vec<Asset>),
28    Pools(Vec<Pool>),
29    PoolsLite(Vec<PoolLite>),
30    PoolTrades(Vec<PoolTrade>),
31    RoutingPlan(Vec<Vec<RoutingPlanStep>>),
32}