Skip to main content

nym_api_requests/
lib.rs

1// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6
7pub mod constants;
8pub mod ecash;
9mod helpers;
10pub mod models;
11pub mod nym_nodes;
12pub mod pagination;
13pub mod signable;
14
15// The response type we fetch from the network details endpoint.
16#[derive(Clone, Debug, Serialize, Deserialize)]
17pub struct NymNetworkDetailsResponse {
18    pub network: nym_config::defaults::NymNetworkDetails,
19}
20
21// The response type we fetch from the v2 network details endpoint.
22#[derive(Clone, Debug, Serialize, Deserialize)]
23pub struct NymNetworkDetailsV2Response {
24    pub network: nym_config::defaults::v2::NymNetworkDetails,
25}
26
27pub trait Deprecatable {
28    fn deprecate(self) -> Deprecated<Self>
29    where
30        Self: Sized,
31    {
32        self.into()
33    }
34}
35
36impl<T> Deprecatable for T {}
37
38#[derive(Serialize, Deserialize, JsonSchema)]
39pub struct Deprecated<T> {
40    pub deprecated: bool,
41    #[serde(flatten)]
42    pub response: T,
43}
44
45impl<T> From<T> for Deprecated<T> {
46    fn from(response: T) -> Self {
47        Deprecated {
48            deprecated: true,
49            response,
50        }
51    }
52}