Skip to main content

nym_api_requests/models/
mod.rs

1// Copyright 2022-2024 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4#![allow(deprecated)]
5
6use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8use std::fmt;
9use std::fmt::{Display, Formatter};
10
11pub mod api_status;
12pub mod circulating_supply;
13pub mod described;
14pub mod directory;
15pub mod geolocation;
16pub mod legacy;
17pub mod mixnet;
18pub mod network;
19pub mod network_monitor;
20pub mod node_families;
21pub mod node_status;
22pub mod performance;
23pub mod schema_helpers;
24pub mod utility;
25
26// don't break existing imports
27pub use api_status::*;
28pub use circulating_supply::*;
29pub use legacy::*;
30pub use mixnet::*;
31pub use network::*;
32pub use network_monitor::*;
33pub use node_status::*;
34pub use schema_helpers::*;
35
36pub use nym_mixnet_contract_common::{EpochId, KeyRotationId, KeyRotationState};
37pub use nym_node_requests::api::v1::node::models::BinaryBuildInformationOwned;
38pub use nym_noise_keys::VersionedNoiseKeyV1;
39
40#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
41pub struct RequestError {
42    message: String,
43}
44
45impl RequestError {
46    pub fn new<S: Into<String>>(msg: S) -> Self {
47        RequestError {
48            message: msg.into(),
49        }
50    }
51
52    pub fn message(&self) -> &str {
53        &self.message
54    }
55
56    pub fn empty() -> Self {
57        Self {
58            message: String::new(),
59        }
60    }
61}
62
63impl Display for RequestError {
64    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
65        Display::fmt(&self.message, f)
66    }
67}