floopy/resources/
routing.rs1use std::sync::Arc;
2
3use reqwest::Method;
4
5use crate::constants::ENDPOINT_ROUTING_EXPLAIN;
6use crate::error::Result;
7use crate::http::HttpTransport;
8use crate::options::RequestOptions;
9use crate::types::{RoutingExplainParams, RoutingExplainResult};
10
11use super::require;
12
13pub struct Routing {
15 t: Arc<HttpTransport>,
16}
17
18impl Routing {
19 pub(crate) fn new(t: Arc<HttpTransport>) -> Self {
20 Self { t }
21 }
22
23 pub async fn explain(
30 &self,
31 params: RoutingExplainParams,
32 req: impl Into<Option<RequestOptions>>,
33 ) -> Result<RoutingExplainResult> {
34 let body =
35 serde_json::to_value(¶ms).map_err(|e| crate::Error::Decode(e.to_string()))?;
36 let (data, _) = self
37 .t
38 .request(
39 Method::POST,
40 ENDPOINT_ROUTING_EXPLAIN,
41 Some(&body),
42 &[],
43 req.into().as_ref(),
44 )
45 .await?;
46 require(data)
47 }
48}