Crate lapin_futures_native_tls [] [src]

lapin-futures-native-tls

This library offers a nice integration of native-tls with the lapin-futures library. It uses amq-protocol URI parsing feature and adds a connect method to AMQPUri which will provide you with a lapin_futures::client::Client wrapped in a Future.

It autodetects whether you're using amqp or amqps and opens either a raw TcpStream or a TlsStream using native-tls as the SSL engine.

Connecting and opening a channel

extern crate env_logger;
extern crate futures;
extern crate lapin_futures_native_tls;
extern crate tokio_core;

use lapin_futures_native_tls::lapin;

use futures::future::Future;
use lapin::channel::ConfirmSelectOptions;
use lapin_futures_native_tls::AMQPConnectionNativeTlsExt;
use tokio_core::reactor::Core;

fn main() {
    env_logger::init();

    let mut core = Core::new().unwrap();
    let handle   = core.handle();

    core.run(
        "amqps://user:pass@host/vhost?heartbeat=10".connect(handle, |_| ()).and_then(|client| {
            println!("Connected!");
            client.create_confirm_channel(ConfirmSelectOptions::default())
        }).and_then(|channel| {
            println!("Closing channel.");
            channel.close(200, "Bye")
        })
    ).unwrap();
}

Modules

lapin

Reexport of the lapin_futures crate

uri

Reexport of the uri module from the amq_protocol crate

Traits

AMQPConnectionNativeTlsExt

Add a connect method providing a lapin_futures::client::Client wrapped in a Future.