-
Notifications
You must be signed in to change notification settings - Fork 3
/
async_client.rs
36 lines (27 loc) · 945 Bytes
/
async_client.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
extern crate futures;
extern crate tibrv;
extern crate tokio;
use std::ffi::CStr;
use tibrv::context::{RvCtx, TransportBuilder};
use tibrv::field::Decodable;
use tibrv::message::Msg;
use tokio::prelude::*;
use tokio::reactor::Handle;
fn main() {
let handle = Handle::default();
let ctx = RvCtx::new().unwrap(); // Create the context, starting Rendezvous internals
let tp = TransportBuilder::new(ctx.clone())
.create()
.expect("Couldn't create default transport");
let mut msg = Msg::new().unwrap();
msg.set_send_subject("TEST.SUBJECT").unwrap();
let response = tp.async_req(&handle, &mut msg).unwrap();
let events = response.then(|msg| {
let unwrapped = msg.unwrap();
let reply = unwrapped.get_field_by_name("reply").unwrap();
let decoded = <&CStr>::tibrv_try_decode(&reply).unwrap();
println!("{:?}", decoded);
Ok(())
});
tokio::run(events)
}