Skip to content

Commit 025a7f3

Browse files
committed
fix: resolve result_large_err by boxing large error variants
Box XRPLWebSocketException inside XRPLClientException and box ServerInfo/ServerState variants in XRPLResult to bring enum sizes below the 128-byte clippy threshold. This resolves all 40 clippy::result_large_err warnings, bringing the codebase to zero clippy warnings under -D warnings.
1 parent 36bec9c commit 025a7f3

5 files changed

Lines changed: 18 additions & 7 deletions

File tree

src/asynch/clients/exceptions.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#[cfg(not(feature = "std"))]
2+
use alloc::boxed::Box;
13
use thiserror_no_std::Error;
24

35
#[cfg(feature = "helpers")]
@@ -23,7 +25,7 @@ pub enum XRPLClientException {
2325
XRPLFaucetError(#[from] XRPLFaucetException),
2426
#[cfg(feature = "websocket")]
2527
#[error("XRPL WebSocket error: {0}")]
26-
XRPLWebSocketError(#[from] XRPLWebSocketException),
28+
XRPLWebSocketError(Box<XRPLWebSocketException>),
2729
#[cfg(feature = "json-rpc")]
2830
#[error("XRPL JSON-RPC error: {0}")]
2931
XRPLJsonRpcError(#[from] XRPLJsonRpcException),
@@ -47,10 +49,17 @@ impl From<reqwless::Error> for XRPLClientException {
4749
}
4850
}
4951

52+
#[cfg(feature = "websocket")]
53+
impl From<XRPLWebSocketException> for XRPLClientException {
54+
fn from(error: XRPLWebSocketException) -> Self {
55+
XRPLClientException::XRPLWebSocketError(Box::new(error))
56+
}
57+
}
58+
5059
#[cfg(all(feature = "std", feature = "websocket"))]
5160
impl From<tokio_tungstenite::tungstenite::Error> for XRPLClientException {
5261
fn from(error: tokio_tungstenite::tungstenite::Error) -> Self {
53-
XRPLClientException::XRPLWebSocketError(XRPLWebSocketException::from(error))
62+
XRPLClientException::XRPLWebSocketError(Box::new(XRPLWebSocketException::from(error)))
5463
}
5564
}
5665

src/models/results/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ pub mod tx;
4141
pub mod unsubscribe;
4242

4343
use super::{requests::XRPLRequest, Amount, XRPLModelException, XRPLModelResult};
44+
#[cfg(not(feature = "std"))]
45+
use alloc::boxed::Box;
4446
use alloc::{
4547
borrow::Cow,
4648
string::{String, ToString},

src/models/transactions/exceptions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub enum XRPLSignerListSetException {
146146
/// A collection contains an invalid value.
147147
#[error("The field `{field:?}` contains an invalid value (found {found:?})")]
148148
CollectionInvalidItem { field: String, found: String },
149-
#[error("The field `signer_quorum` ({found:?}) must be below or equal to the sum of `signer_weight` in `signer_entries` ({max:?})")]
149+
#[error("The field `signer_quorum` must be below or equal to the sum of `signer_weight` in `signer_entries` (max {max}, found {found})")]
150150
SignerQuorumExceedsSignerWeight { max: u32, found: u32 },
151151
}
152152

src/models/transactions/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ where
269269
{
270270
pub fn is_signed(&self) -> bool {
271271
if let Some(signers) = &self.signers {
272-
signers
273-
.iter()
274-
.all(|signer| !signer.txn_signature.is_empty() && !signer.signing_pub_key.is_empty())
272+
signers.iter().all(|signer| {
273+
!signer.txn_signature.is_empty() && !signer.signing_pub_key.is_empty()
274+
})
275275
} else {
276276
self.txn_signature.is_some() && self.signing_pub_key.is_some()
277277
}

src/models/transactions/signer_list_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ mod tests {
363363

364364
assert_eq!(
365365
signer_list_set.validate().unwrap_err().to_string().as_str(),
366-
"The field `signer_quorum` (10) must be below or equal to the sum of `signer_weight` in `signer_entries` (3)"
366+
"The field `signer_quorum` must be below or equal to the sum of `signer_weight` in `signer_entries` (max 3, found 10)"
367367
);
368368

369369
signer_list_set.signer_entries = Some(vec![

0 commit comments

Comments
 (0)