-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathevents.rs
55 lines (44 loc) · 1.43 KB
/
events.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//!
//! Rust Firebird Client
//!
//! Examples of events traits
//!
#![allow(unused_variables, unused_mut)]
use rsfbclient::{FbError, Queryable, RemoteEventsManager};
fn main() -> Result<(), FbError> {
#[cfg(not(feature = "pure_rust"))] // No support for events with pure rust driver
{
#[cfg(feature = "linking")]
let mut conn = rsfbclient::builder_native()
.with_dyn_link()
.with_remote()
.host("localhost")
.db_name("examples.fdb")
.user("SYSDBA")
.pass("masterkey")
.connect()?;
#[cfg(feature = "dynamic_loading")]
let mut conn = rsfbclient::builder_native()
.with_dyn_load("./fbclient.lib")
.with_remote()
.host("localhost")
.db_name("examples.fdb")
.user("SYSDBA")
.pass("masterkey")
.connect()?;
let wt = conn.listen_event("ping".to_string(), move |c| {
println!("Pong! Some rows here:");
let rows: Vec<(String, String)> = c.query(
"select mon$attachment_name, mon$user from mon$attachments",
(),
)?;
for row in rows {
println!("Attachment {}, user {}", row.0, row.1);
}
return Ok(true);
})?;
println!("Try ping here with \"POST_EVENT 'ping'\"");
wt.join().unwrap()?;
}
Ok(())
}