fix(ffi): return parser status and isolate thread errors
This commit is contained in:
parent
740cf9c693
commit
24438c4840
1 changed files with 234 additions and 24 deletions
20
tests/common/mod.rs
Normal file
20
tests/common/mod.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use klamath_rs_ext::{basic::encode_real8, records};
|
||||
|
||||
pub fn record(out: &mut Vec<u8>, tag: u16, data: &[u8]) {
|
||||
out.extend_from_slice(&u16::try_from(data.len() + 4).unwrap().to_be_bytes());
|
||||
out.extend_from_slice(&tag.to_be_bytes());
|
||||
out.extend_from_slice(data);
|
||||
}
|
||||
|
||||
pub fn library_header() -> Vec<u8> {
|
||||
let mut bytes = Vec::new();
|
||||
record(&mut bytes, records::RTAG_HEADER, &600_i16.to_be_bytes());
|
||||
record(&mut bytes, records::RTAG_BGNLIB, &[0; 24]);
|
||||
record(&mut bytes, records::RTAG_LIBNAME, b"test");
|
||||
let units: Vec<u8> = [0.001, 1e-9]
|
||||
.into_iter()
|
||||
.flat_map(|v| encode_real8(v).unwrap().to_be_bytes())
|
||||
.collect();
|
||||
record(&mut bytes, records::RTAG_UNITS, &units);
|
||||
bytes
|
||||
}
|
||||
Loading…
Reference in a new issue