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:16:22 +02:00
|
|
|
match String::from_utf8(response) {
|
|
|
|
Ok(string) => Ok(string),
|
|
|
|
Err(err) => {
|
|
|
|
log::error!("unable to decode result from bytes: {:#x?}", bytes);
|
|
|
|
Err(err_msg(&format!(
|
|
|
|
"unable to decode result from bytes {:#x?}: {}",
|
|
|
|
bytes, err
|
|
|
|
)))
|
|
|
|
}
|
2019-08-17 00:58:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|