16 lines
454 B
Rust
Raw Normal View History

2019-08-17 00:58:17 +03:00
use crate::errors::{err_msg, AppResult};
use crate::sqlite;
2019-08-18 18:16:22 +02:00
pub fn query(bytes: &str) -> AppResult<String> {
let response = sqlite::call(bytes.as_bytes());
2019-08-17 00:58:17 +03:00
// Decode query result to a utf8 string
2019-08-18 18:19:35 +02:00
String::from_utf8(response).map_err(|e| {
log::error!("unable to decode result from bytes: {:#x?}", bytes);
err_msg(&format!(
"unable to decode result from bytes {:#x?}: {}",
bytes, e
))
})
2019-08-17 00:58:17 +03:00
}