Прослушивание событий на определенном канале для PostgreSQL происходит следующим образом: -
// Establish connection with database.
let url = "postgresql://root:root1234@127.0.01/test";
let conn = Connection::connect(url, TlsMode::None).unwrap();
// Listen for events on channel 'myevent'.
conn.execute("LISTEN myevent", &[]).expect("Could not send LISTEN");
let notifications = conn.notifications();
let mut it = notifications.blocking_iter();
println!("Waiting for notifications...");
loop {
let a = it.next();
match a {
Ok(Some(b)) => {
println!("{:?}", b);
},
Err(e) => println!("Got error {:?}", e),
_ => panic!("Unexpected operation!!!")
}
}