in amazon-qldb-driver-core/src/ion_compat.rs [32:45]
fn buf_to_str(buf: Vec<u8>) -> Result<String, Utf8Error> {
// This should never be possible - writer is given a 4mb buffer
// and should be writing a null terminated string. So if the last
// byte is not NULL, something has gone horrifically wrong.
if *buf.last().unwrap() != b'\0' {
unreachable!()
}
unsafe {
CStr::from_ptr(buf.as_ptr() as *const _)
.to_str()
.map(|s| s.trim_end().to_owned())
}
}