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 legacy;
15pub mod mixnet;
16pub mod network;
17pub mod network_monitor;
18pub mod node_families;
19pub mod node_status;
20pub mod schema_helpers;
21pub mod utility;
22
23// don't break existing imports
24pub use api_status::*;
25pub use circulating_supply::*;
26pub use legacy::*;
27pub use mixnet::*;
28pub use network::*;
29pub use network_monitor::*;
30pub use node_status::*;
31pub use schema_helpers::*;
32
33pub use nym_mixnet_contract_common::{EpochId, KeyRotationId, KeyRotationState};
34pub use nym_node_requests::api::v1::node::models::BinaryBuildInformationOwned;
35pub use nym_noise_keys::VersionedNoiseKeyV1;
36
37#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
38pub struct RequestError {
39    message: String,
40}
41
42impl RequestError {
43    pub fn new<S: Into<String>>(msg: S) -> Self {
44        RequestError {
45            message: msg.into(),
46        }
47    }
48
49    pub fn message(&self) -> &str {
50        &self.message
51    }
52
53    pub fn empty() -> Self {
54        Self {
55            message: String::new(),
56        }
57    }
58}
59
60impl Display for RequestError {
61    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
62        Display::fmt(&self.message, f)
63    }
64}