Skip to content

Instantly share code, notes, and snippets.

@docteurklein
Created September 17, 2019 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save docteurklein/ed220cac282d2d8edf154b594feec6ea to your computer and use it in GitHub Desktop.
Save docteurklein/ed220cac282d2d8edf154b594feec6ea to your computer and use it in GitHub Desktop.
error[E0599]: no method named `map` found for type `postgres::notification::BlockingIter<'_>` in the current scope
  --> src/main.rs:24:19
   |
24 |     notifications.map(|notification| {
   |                   ^^^
   |
   = note: the method `map` exists but the following trait bounds were not satisfied:
           `&mut postgres::notification::BlockingIter<'_> : fallible_iterator::FallibleIterator`
           `&mut postgres::notification::BlockingIter<'_> : std::iter::Iterator`
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
   |
5  | use fallible_iterator::FallibleIterator;
   |

extern crate hyper_sse;
extern crate postgres;
#[macro_use] extern crate lazy_static;
use hyper_sse::Server;
use postgres::{Connection, TlsMode};
use fallible_iterator::FallibleIterator;
use std::iter::Iterator;
lazy_static! {
static ref SSE: Server<u8> = Server::new();
}
fn main() {
SSE.spawn("[::1]:3000".parse().unwrap());
let auth_token = SSE.generate_auth_token(Some(0)).unwrap();
println!("http://[::1]:3000/push/0?{}", auth_token);
let conn = Connection::connect("postgres://postgres@localhost", TlsMode::None).unwrap();
conn.execute("LISTEN test", &[]).unwrap();
let mut notifications = conn.notifications().blocking_iter();
notifications.map(|notification| {
SSE.push(0, "update", &"test").ok();
});
}
@docteurklein
Copy link
Author

turns out I was using the wrong version of fallible_iterator

@rizky
Copy link

rizky commented Feb 19, 2021

stumbled on the same issue, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment