mirror of
https://github.com/fluencelabs/fluid
synced 2025-06-20 16:46:30 +00:00
Fix compilation & warnings
This commit is contained in:
@ -11,12 +11,17 @@ pub fn add_post(message: String, username: String) -> AppResult<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_all_posts(offset: u32, count: u32) -> AppResult<String> {
|
pub fn get_all_posts(offset: u32, count: u32) -> AppResult<String> {
|
||||||
log::info!("get all posts");
|
log::info!("get all posts {} {}", offset, count);
|
||||||
Ok("[]".to_string())
|
Ok("[]".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_posts_by_username(username: String, offset: u32, count: u32) -> AppResult<String> {
|
pub fn get_posts_by_username(username: String, offset: u32, count: u32) -> AppResult<String> {
|
||||||
log::info!("get all posts by username {}", username);
|
log::info!(
|
||||||
|
"get all posts by username {} {} {}",
|
||||||
|
username,
|
||||||
|
offset,
|
||||||
|
count
|
||||||
|
);
|
||||||
Ok("[]".to_string())
|
Ok("[]".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,12 +4,21 @@ use crate::sqlite;
|
|||||||
pub fn query(query: &str) -> AppResult<String> {
|
pub fn query(query: &str) -> AppResult<String> {
|
||||||
let response = sqlite::call(query.as_bytes());
|
let response = sqlite::call(query.as_bytes());
|
||||||
|
|
||||||
// Add more details to error message
|
// Decode query result to a utf8 string
|
||||||
String::from_utf8(response).map_err(|e| {
|
let result_str = std::str::from_utf8(&response);
|
||||||
|
|
||||||
|
// Log if there's an error
|
||||||
|
if result_str.is_err() {
|
||||||
log::error!("unable to decode result from bytes: {:#x?}", response);
|
log::error!("unable to decode result from bytes: {:#x?}", response);
|
||||||
err_msg(&format!(
|
}
|
||||||
"unable to decode result from bytes {:#x?}: {}",
|
|
||||||
query, e
|
// Wrap error with a better message, and return Result
|
||||||
))
|
result_str
|
||||||
})
|
.map_err(|e| {
|
||||||
|
err_msg(&format!(
|
||||||
|
"unable to decode result from bytes {:#x?}: {}",
|
||||||
|
response, e
|
||||||
|
))
|
||||||
|
})
|
||||||
|
.map(|s| s.to_string())
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,21 @@ use crate::sqlite;
|
|||||||
pub fn query(query: &str) -> AppResult<String> {
|
pub fn query(query: &str) -> AppResult<String> {
|
||||||
let response = sqlite::call(query.as_bytes());
|
let response = sqlite::call(query.as_bytes());
|
||||||
|
|
||||||
// Add more details to error message
|
// Decode query result to a utf8 string
|
||||||
String::from_utf8(response).map_err(|e| {
|
let result_str = std::str::from_utf8(&response);
|
||||||
|
|
||||||
|
// Log if there's an error
|
||||||
|
if result_str.is_err() {
|
||||||
log::error!("unable to decode result from bytes: {:#x?}", response);
|
log::error!("unable to decode result from bytes: {:#x?}", response);
|
||||||
err_msg(&format!(
|
}
|
||||||
"unable to decode result from bytes {:#x?}: {}",
|
|
||||||
query, e
|
// Wrap error with a better message, and return Result
|
||||||
))
|
result_str
|
||||||
})
|
.map_err(|e| {
|
||||||
|
err_msg(&format!(
|
||||||
|
"unable to decode result from bytes {:#x?}: {}",
|
||||||
|
response, e
|
||||||
|
))
|
||||||
|
})
|
||||||
|
.map(|s| s.to_string())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user