Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- impl Handler<QueryDocuments> for PgConnection {
- type Result = ResponseFuture<Result<RequestedDocuments, io::Error>>;
- fn handle(&mut self, msg: QueryDocuments, _: &mut Self::Context) -> Self::Result {
- let documents = FuturesUnordered::new();
- for _ in 0..msg.0 {
- let w_id = 1 as i32;
- documents.push(
- self.client
- .query_one(&self.query_documents, &[&w_id])
- .map(|res| match res {
- Err(e) => {
- Err(io::Error::new(io::ErrorKind::Other, format!("{:?}", e)))
- }
- Ok(row) => Ok(RequestedDocument {
- id: 1,
- content: None,
- score: 0.0,
- }),
- }),
- );
- }
- Box::pin(documents.try_collect())
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement