1#![cfg_attr(not(feature = "std"), no_std)]
21#![allow(dead_code)] #![allow(clippy::result_large_err)]
23
24use ::core::fmt::Display;
25
26use alloc::string::{String, ToString};
27use thiserror_no_std::Error;
28
29#[cfg(not(feature = "std"))]
30extern crate alloc;
31#[cfg(feature = "std")]
32extern crate std as alloc;
33
34#[cfg(feature = "helpers")]
35pub mod account;
36#[cfg(feature = "models")]
39pub mod asynch;
40#[cfg(feature = "cli")]
41pub mod cli;
42#[cfg(any(feature = "json-rpc", feature = "websocket"))]
43pub mod clients;
44pub mod constants;
45#[cfg(feature = "core")]
46pub mod core;
47#[cfg(feature = "helpers")]
48pub mod ledger;
49pub mod macros;
50#[cfg(feature = "models")]
51pub mod models;
52#[cfg(all(feature = "core", feature = "models", feature = "wallet"))]
53pub mod signing;
54#[cfg(feature = "helpers")]
55pub mod transaction;
56#[cfg(feature = "utils")]
57pub mod utils;
58#[cfg(feature = "wallet")]
59pub mod wallet;
60
61pub extern crate serde_json;
62
63#[cfg(feature = "models")]
64mod _serde;
65
66#[cfg(all(
67 feature = "helpers",
68 not(any(
69 feature = "tokio-rt",
70 feature = "embassy-rt",
71 feature = "actix-rt",
72 feature = "async-std-rt",
73 feature = "futures-rt",
74 feature = "smol-rt"
75 ))
76))]
77compile_error!("Cannot enable `helpers` without enabling a runtime feature (\"*-rt\"). This is required for sleeping between retries internally.");
78#[cfg(all(
79 feature = "helpers",
80 not(any(feature = "json-rpc", feature = "websocket",))
81))]
82compile_error!("Cannot enable `helpers` without enabling a client feature (\"json-rpc\", \"websocket\"). This is required for interacting with the XRP Ledger.");
83
84#[derive(Debug, Error)]
85pub enum XRPLSerdeJsonError {
86 SerdeJsonError(serde_json::Error),
87 InvalidNoneError(String),
88 UnexpectedValueType {
89 expected: String,
90 found: serde_json::Value,
91 },
92}
93
94impl Display for XRPLSerdeJsonError {
95 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
96 match self {
97 XRPLSerdeJsonError::SerdeJsonError(err) => write!(f, "{}", err),
98 XRPLSerdeJsonError::InvalidNoneError(err) => {
99 write!(f, "Invalid None value on field: {}", err)
100 }
101 XRPLSerdeJsonError::UnexpectedValueType { expected, found } => {
102 write!(
103 f,
104 "Unexpected value type (expected: {}, found: {})",
105 expected, found
106 )
107 }
108 }
109 }
110}
111
112impl From<serde_json::Error> for XRPLSerdeJsonError {
113 fn from(err: serde_json::Error) -> Self {
114 XRPLSerdeJsonError::SerdeJsonError(err)
115 }
116}
117
118impl PartialEq for XRPLSerdeJsonError {
119 fn eq(&self, other: &Self) -> bool {
120 self.to_string() == other.to_string()
121 }
122}