Last active
January 1, 2019 15:04
-
-
Save jkilpatr/638f1559dc6e4cf58c0c783f292e4b62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn data_deserialize<'de, D>(d: D) -> Result<Vec<u8>, D::Error> | |
where | |
D: Deserializer<'de>, | |
{ | |
println!("do we hit this function?"); | |
let s = match String::deserialize(d) { | |
Ok(s) => s, | |
Err(e) => { | |
println!("Did not find a string {}", e); | |
return Err(e); | |
} | |
}; | |
match hex_str_to_bytes(&s) { | |
Ok(v) => Ok(v), | |
Err(e) => { | |
println!("Error in hex decoding is {}", e); | |
Err(serde::de::Error::custom(e)) | |
} | |
} | |
} | |
#[derive(Deserialize, Debug)] | |
pub struct TestDecode { | |
#[serde(rename = "transactionHash")] | |
pub transaction_hash: Uint256, | |
} | |
#[test] | |
fn decode_num256() { | |
let test_string = "{\"transactionHash\":\"0xd6785de92c3d55e22a50ef6a37553b1abd4fc710d3662e38369656d4e747662b\"}"; | |
println!("{}", test_string); | |
let _res: TestDecode = serde_json::from_str(test_string).unwrap(); | |
} | |
---- types::decode_num256 stdout ---- | |
{"transactionHash":"0xd6785de92c3d55e22a50ef6a37553b1abd4fc710d3662e38369656d4e747662b"} | |
thread 'types::decode_num256' panicked at 'called `Result::unwrap()` on an `Err` value: Error("invalid digit found in string", line: 1, column: 88)', libcore/result.rs:1009:5 | |
stack backtrace: | |
0: 0x55750f5c856f - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h1fd4e34c3d03ef64 | |
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49 | |
1: 0x55750f5d15d7 - std::sys_common::backtrace::print::h714a469856413294 | |
at libstd/sys_common/backtrace.rs:71 | |
at libstd/sys_common/backtrace.rs:59 | |
2: 0x55750f5cc2bf - std::panicking::default_hook::{{closure}}::h46fe49f863fa9721 | |
at libstd/panicking.rs:211 | |
3: 0x55750f5cbfbe - std::panicking::default_hook::h12f83bcd26b03624 | |
at libstd/panicking.rs:221 | |
4: 0x55750f5cc99e - std::panicking::rust_panic_with_hook::hde420d6fd4455550 | |
at libstd/panicking.rs:476 | |
5: 0x55750f5cc541 - std::panicking::continue_panic_fmt::h8f394f3c578bcc76 | |
at libstd/panicking.rs:390 | |
6: 0x55750f5cc425 - rust_begin_unwind | |
at libstd/panicking.rs:325 | |
7: 0x55750f60fb6c - core::panicking::panic_fmt::hca5dc4e8b320bc56 | |
at libcore/panicking.rs:77 | |
8: 0x55750f517240 - core::result::unwrap_failed::h0b0580712feb85a2 | |
at libcore/macros.rs:26 | |
9: 0x55750f515ade - <core::result::Result<T, E>>::unwrap::h165bd3a7179129b9 | |
at libcore/result.rs:808 | |
10: 0x55750f4ba75a - web3::types::decode_num256::hcd27048bbbecef39 | |
at web3/src/types.rs:189 | |
11: 0x55750f50a919 - web3::types::decode_num256::{{closure}}::hab0eb8f6704b9227 | |
at web3/src/types.rs:186 | |
12: 0x55750f4f691d - core::ops::function::FnOnce::call_once::h6233e114506d2a45 | |
at libcore/ops/function.rs:238 | |
13: 0x55750f51ecfe - <F as alloc::boxed::FnBox<A>>::call_box::hdf40d97683d9649e | |
at libtest/lib.rs:1468 | |
at libcore/ops/function.rs:238 | |
at liballoc/boxed.rs:672 | |
14: 0x55750f5dc589 - __rust_maybe_catch_panic | |
at libpanic_unwind/lib.rs:102 | |
15: 0x55750f540972 - std::sys_common::backtrace::__rust_begin_short_backtrace::hf298948d9e20b61e | |
at libstd/panicking.rs:289 | |
at libstd/panic.rs:392 | |
at libtest/lib.rs:1423 | |
at libstd/sys_common/backtrace.rs:136 | |
16: 0x55750f5413b4 - std::panicking::try::do_call::h2b3625fa2f3b0c89 | |
at libstd/thread/mod.rs:409 | |
at libstd/panic.rs:313 | |
at libstd/panicking.rs:310 | |
17: 0x55750f5dc589 - __rust_maybe_catch_panic | |
at libpanic_unwind/lib.rs:102 | |
18: 0x55750f52e63c - <F as alloc::boxed::FnBox<A>>::call_box::h3b07e951b4d3ee63 | |
at libstd/panicking.rs:289 | |
at libstd/panic.rs:392 | |
at libstd/thread/mod.rs:408 | |
at liballoc/boxed.rs:672 | |
19: 0x55750f5ca1bd - std::sys_common::thread::start_thread::h44127e03e78ca137 | |
at liballoc/boxed.rs:682 | |
at libstd/sys_common/thread.rs:24 | |
20: 0x55750f5bf935 - std::sys::unix::thread::Thread::new::thread_start::h8f17b97f2223146c | |
at libstd/sys/unix/thread.rs:90 | |
21: 0x7ff3ec287593 - start_thread | |
22: 0x7ff3ebda2f4e - clone | |
23: 0x0 - <unknown> | |
---- types::decode_transaction_response stdout ---- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment