Advertisement
Guest User

Untitled

a guest
Feb 1st, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. impl Handler<QueryDocuments> for PgConnection {
  2. type Result = ResponseFuture<Result<RequestedDocuments, io::Error>>;
  3.  
  4. fn handle(&mut self, msg: QueryDocuments, _: &mut Self::Context) -> Self::Result {
  5. let documents = FuturesUnordered::new();
  6. for _ in 0..msg.0 {
  7. let w_id = 1 as i32;
  8. documents.push(
  9. self.client
  10. .query_one(&self.query_documents, &[&w_id])
  11. .map(|res| match res {
  12. Err(e) => {
  13. Err(io::Error::new(io::ErrorKind::Other, format!("{:?}", e)))
  14. }
  15. Ok(row) => Ok(RequestedDocument {
  16. id: 1,
  17. content: None,
  18. score: 0.0,
  19. }),
  20. }),
  21. );
  22. }
  23.  
  24. Box::pin(documents.try_collect())
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement