1
0
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-07-18 05:31:56 +00:00

Add some logging useful in debugging

Ended up helping diagnose the problem in the end!
This commit is contained in:
Alex Crichton
2019-03-21 08:30:30 -07:00
parent d49d8c9e1b
commit 12355ce81c
2 changed files with 9 additions and 5 deletions
crates/cli-support/src

@@ -42,16 +42,15 @@ impl<'src> Decode<'src> for &'src str {
let n = u32::decode(data);
let (a, b) = data.split_at(n as usize);
*data = b;
str::from_utf8(a).unwrap()
let r = str::from_utf8(a).unwrap();
log::trace!("decoded string {:?}", r);
r
}
}
impl<'src> Decode<'src> for String {
fn decode(data: &mut &'src [u8]) -> String {
let n = u32::decode(data);
let (a, b) = data.split_at(n as usize);
*data = b;
String::from_utf8(a.to_vec()).unwrap()
<&'src str>::decode(data).to_string()
}
}
@@ -59,6 +58,7 @@ impl<'src, T: Decode<'src>> Decode<'src> for Vec<T> {
fn decode(data: &mut &'src [u8]) -> Self {
let n = u32::decode(data);
let mut v = Vec::with_capacity(n as usize);
log::trace!("found a list of length {}", n);
for _ in 0..n {
v.push(Decode::decode(data));
}
@@ -84,6 +84,7 @@ macro_rules! decode_struct {
impl <'a> Decode<'a> for $name <$($lt)*> {
fn decode(_data: &mut &'a [u8]) -> Self {
log::trace!("start decode `{}`", stringify!($name));
$name {
$($field: Decode::decode(_data),)*
}