1
Fork 0

Add build variants with feature trace, fix build for those variants.

This commit is contained in:
Alex Helfet 2017-12-24 21:35:18 +00:00
parent 93ac105fbe
commit a8a00555b5
3 changed files with 9 additions and 7 deletions

View file

@ -1,12 +1,13 @@
#!/usr/bin/env bash
set -ex
# A simple build script to run locally.
# A simple build script to run locally before pushing.
for tc in stable beta nightly; do
for tc in nightly stable beta; do
echo "Toolchain: ${tc}";
rustup toolchain update ${tc};
cargo +${tc} test --verbose;
cargo +${tc} test --verbose --no-default-features;
cargo +${tc} test --verbose --features=trace;
cargo +${tc} doc --verbose;
done

View file

@ -6,4 +6,5 @@ set -x
cargo test --verbose;
cargo test --verbose --no-default-features;
cargo test --verbose --no-default-features --features=trace;
cargo doc --verbose;

View file

@ -198,7 +198,7 @@ pub fn encode_to_slice(p: &Payload, dest: &mut [u8]) -> Result<usize> {
dest[footer_idx] = FRAME_END_SYMBOL;
#[cfg(feature = "trace")] {
println!("framed: Frame code = {:?}", dest[0..(footer_idx + 1)]);
println!("framed: Frame code = {:?}", &dest[0..(footer_idx + 1)]);
}
Ok(cobs_len + HEADER_LEN + FOOTER_LEN)
}
@ -266,16 +266,16 @@ pub fn decode_to_slice(e: &Encoded, mut dest: &mut [u8])
let body = &e[0..(e.len()-1)];
let len = cobs::decode(body, &mut dest)
.map_err(|_| Error::CobsDecodeFailed);
.map_err(|_| Error::CobsDecodeFailed)?;
#[cfg(feature = "trace")] {
println!("framed: frame = {:?}\n\
println!("framed: dest = {:?}\n\
framed: body = {:?}\n\
framed: decoded = {:?}",
frame, body, dest[0..len]);
&dest, body, &dest[0..len]);
}
Ok(len?)
Ok(len)
}
/// Decode the supplied encoded frame, returning the payload on the heap.