-
Notifications
You must be signed in to change notification settings - Fork 134
Closed
Description
I need these to be able to do:
extern crate mysql_async as my;
use my::{QueryResult, Protocol, ConnectionLike};
use my::prelude::FromRow;
use tokio_async_await::compat::forward::IntoAwaitable;
pub async fn get_all_results<TupleType, T, P>(result : QueryResult<T, P>) -> Result<Vec<TupleType>, my::error::Error>
where TupleType: FromRow + Send + 'static,
P: Protocol + Send + 'static,
T: ConnectionLike + Sized + Send + 'static, {
let mut fut = result.collect();
let (_, data) :(_, Vec<TupleType>) = match await!(fut.into_awaitable()) {
Ok(r) => r,
Err(e) => {return Err(e);}
};
Ok(data)
}
pub async fn get_single_result<TupleType, T, P>(result : QueryResult<T, P>) -> Result<TupleType, my::error::Error>
where TupleType: FromRow + Send + 'static,
P: Protocol + Send + 'static,
T: ConnectionLike + Sized + Send + 'static, {
let mut data : Vec<TupleType> = await!(get_all_results(result))?;
if data.len() != 1 {
Err(my::error::Error::Io(std::io::Error::from(std::io::ErrorKind::InvalidData)))
}else {
Ok(data.remove(0))
}
}```
right now I need to use modified version to to make them public exported.Metadata
Metadata
Assignees
Labels
No labels