Skip to content

Commit 9ee2cc8

Browse files
authored
node-api: Box Error::DecodeValue and Error::EncodeValue (#700)
1 parent 02bfcef commit 9ee2cc8

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ jobs:
6161
cargo build --release -p ac-examples --example runtime_update_async --no-default-features,
6262

6363
# Clippy
64-
cargo clippy --workspace --exclude test-no-std -- -D warnings,
64+
cargo clippy -- -D warnings,
65+
cargo clippy --no-default-features -- -D warnings,
6566
cargo clippy --all-features --examples -- -D warnings,
6667

6768
# Run tests and build examples

node-api/src/error/mod.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
//! General node-api Error implementation.
1010
11-
use alloc::{string::String, vec::Vec};
11+
use alloc::{boxed::Box, string::String, vec::Vec};
1212
use core::fmt::Debug;
1313
use derive_more::From;
1414

@@ -40,9 +40,9 @@ pub enum Error {
4040
/// Runtime error.
4141
Runtime(DispatchError),
4242
/// Error decoding to a [`crate::dynamic::Value`].
43-
DecodeValue(DecodeError),
43+
DecodeValue(Box<DecodeError>),
4444
/// Error encoding from a [`crate::dynamic::Value`].
45-
EncodeValue(EncodeError),
45+
EncodeValue(Box<EncodeError>),
4646
/// The bytes representing an error that we were unable to decode.
4747
Unknown(Vec<u8>),
4848
/// Other error.
@@ -54,3 +54,15 @@ impl From<&str> for Error {
5454
Error::Other(error.into())
5555
}
5656
}
57+
58+
impl From<DecodeError> for Error {
59+
fn from(error: DecodeError) -> Self {
60+
Error::DecodeValue(Box::new(error))
61+
}
62+
}
63+
64+
impl From<EncodeError> for Error {
65+
fn from(error: EncodeError) -> Self {
66+
Error::EncodeValue(Box::new(error))
67+
}
68+
}

0 commit comments

Comments
 (0)