Struct lapin_futures_tls_api::lapin::client::Client

source ·
pub struct Client<T> {
    pub configuration: Configuration,
    /* private fields */
}
Expand description

the Client structures connects to a server and creates channels

Fields§

§configuration: Configuration

Implementations§

source§

impl<T> Client<T>
where T: AsyncRead + AsyncWrite + Send + Sync + 'static,

source

pub fn connect( stream: T, options: ConnectionOptions, ) -> impl Future<Item = (Client<T>, Heartbeat<impl Future<Item = (), Error = Error> + Send + 'static>), Error = Error> + Send + 'static

Takes a stream (TCP, TLS, unix socket, etc) and uses it to connect to an AMQP server.

This function returns a future that resolves once the connection handshake is done. The result is a tuple containing a Client that can be used to create Channels and a Heartbeat instance. The heartbeat is a task (it implements Future) that should be spawned independently of the other futures.

To stop the heartbeat task, see HeartbeatHandle.

§Example
use tokio::net::TcpStream;
use tokio::runtime::Runtime;
use lapin_futures::client::{Client, ConnectionOptions};

let addr = "127.0.0.1:5672".parse().unwrap();
let f = TcpStream::connect(&addr)
    .and_then(|stream| {
        Client::connect(stream, ConnectionOptions::default())
    })
    .and_then(|(client, mut heartbeat)| {
        let handle = heartbeat.handle().unwrap();
        tokio::spawn(
            heartbeat.map_err(|e| eprintln!("The heartbeat task errored: {}", e))
        );

        /// ...

        handle.stop();
        Ok(())
    });
Runtime::new().unwrap().block_on_all(
    f.map_err(|e| eprintln!("An error occured: {}", e))
).expect("runtime exited with failure");
source

pub fn create_channel( &self, ) -> impl Future<Item = Channel<T>, Error = Error> + Send + 'static

creates a new channel

returns a future that resolves to a Channel once the method succeeds

source

pub fn create_confirm_channel( &self, options: ConfirmSelectOptions, ) -> impl Future<Item = Channel<T>, Error = Error> + Send + 'static

returns a future that resolves to a Channel once the method succeeds the channel will support RabbitMQ’s confirm extension

Trait Implementations§

source§

impl<T> Clone for Client<T>
where T: Send,

source§

fn clone(&self) -> Client<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Client<T>

§

impl<T> RefUnwindSafe for Client<T>

§

impl<T> Send for Client<T>
where T: Send,

§

impl<T> Sync for Client<T>
where T: Send,

§

impl<T> Unpin for Client<T>

§

impl<T> UnwindSafe for Client<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.