Support deserialization into byte arrays for BLOB's via serde_bytes.

This commit is contained in:
Stephen Chung
2021-12-02 14:10:53 +08:00
parent 70f4c53854
commit 41dd989866
6 changed files with 49 additions and 13 deletions

View File

@@ -775,3 +775,23 @@ fn test_serde_optional() -> Result<(), Box<EvalAltResult>> {
Ok(())
}
#[test]
#[cfg(not(feature = "no_index"))]
fn test_serde_blob() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
let r = engine.eval::<Dynamic>(
"
let x = blob(10);
for i in range(0, 10) { x[i] = i; }
x
",
)?;
let r = from_dynamic::<serde_bytes::ByteBuf>(&r)?;
assert_eq!(r.to_vec(), vec![0_u8, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
Ok(())
}