Struct Channel

Source
pub struct Channel<T> {
    pub transport: Arc<Mutex<RawMutex, AMQPTransport<T>>>,
    pub id: u16,
}
Expand description

Channel provides methods to act on a channel, such as managing queues

Fields§

§transport: Arc<Mutex<RawMutex, AMQPTransport<T>>>§id: u16

Implementations§

Source§

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

Source

pub fn create( transport: Arc<Mutex<RawMutex, AMQPTransport<T>>>, ) -> impl Future<Item = Channel<T>, Error = Error> + Send + 'static

create a channel

Source

pub fn access_request( &self, realm: &str, options: AccessRequestOptions, ) -> impl Future<Item = (), Error = Error> + Send + 'static

request access

returns a future that resolves once the access is granted

Source

pub fn exchange_declare( &self, name: &str, exchange_type: &str, options: ExchangeDeclareOptions, arguments: BTreeMap<String, AMQPValue>, ) -> impl Future<Item = (), Error = Error> + Send + 'static

declares an exchange

returns a future that resolves once the exchange is available

Source

pub fn exchange_delete( &self, name: &str, options: ExchangeDeleteOptions, ) -> impl Future<Item = (), Error = Error> + Send + 'static

deletes an exchange

returns a future that resolves once the exchange is deleted

Source

pub fn exchange_bind( &self, destination: &str, source: &str, routing_key: &str, options: ExchangeBindOptions, arguments: BTreeMap<String, AMQPValue>, ) -> impl Future<Item = (), Error = Error> + Send + 'static

binds an exchange to another exchange

returns a future that resolves once the exchanges are bound

Source

pub fn exchange_unbind( &self, destination: &str, source: &str, routing_key: &str, options: ExchangeUnbindOptions, arguments: BTreeMap<String, AMQPValue>, ) -> impl Future<Item = (), Error = Error> + Send + 'static

unbinds an exchange from another one

returns a future that resolves once the exchanges are unbound

Source

pub fn queue_declare( &self, name: &str, options: QueueDeclareOptions, arguments: BTreeMap<String, AMQPValue>, ) -> impl Future<Item = Queue, Error = Error> + Send + 'static

declares a queue

returns a future that resolves once the queue is available

the mandatory and ìmmediate options can be set to true, but the return message will not be handled

Source

pub fn queue_bind( &self, name: &str, exchange: &str, routing_key: &str, options: QueueBindOptions, arguments: BTreeMap<String, AMQPValue>, ) -> impl Future<Item = (), Error = Error> + Send + 'static

binds a queue to an exchange

returns a future that resolves once the queue is bound to the exchange

Source

pub fn queue_unbind( &self, name: &str, exchange: &str, routing_key: &str, options: QueueUnbindOptions, arguments: BTreeMap<String, AMQPValue>, ) -> impl Future<Item = (), Error = Error> + Send + 'static

unbinds a queue from the exchange

returns a future that resolves once the queue is unbound from the exchange

Source

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

sets up confirm extension for this channel

Source

pub fn basic_qos( &self, options: BasicQosOptions, ) -> impl Future<Item = (), Error = Error> + Send + 'static

specifies quality of service for a channel

Source

pub fn basic_publish( &self, exchange: &str, routing_key: &str, payload: Vec<u8>, options: BasicPublishOptions, properties: AMQPProperties, ) -> impl Future<Item = Option<u64>, Error = Error> + Send + 'static

publishes a message on a queue

the future’s result is:

  • Some(request_id) if we’re on a confirm channel and the message was ack’d
  • None if we’re not on a confirm channel or the message was nack’d
Source

pub fn basic_consume( &self, queue: &Queue, consumer_tag: &str, options: BasicConsumeOptions, arguments: BTreeMap<String, AMQPValue>, ) -> impl Future<Item = Consumer<T>, Error = Error> + Send + 'static

creates a consumer stream

returns a future of a Consumer that resolves once the method succeeds

Consumer implements futures::Stream, so it can be used with any of the usual combinators

Source

pub fn basic_ack( &self, delivery_tag: u64, multiple: bool, ) -> impl Future<Item = (), Error = Error> + Send + 'static

acks a message

Source

pub fn basic_nack( &self, delivery_tag: u64, multiple: bool, requeue: bool, ) -> impl Future<Item = (), Error = Error> + Send + 'static

nacks a message

Source

pub fn basic_reject( &self, delivery_tag: u64, requeue: bool, ) -> impl Future<Item = (), Error = Error> + Send + 'static

rejects a message

Source

pub fn basic_get( &self, queue: &str, options: BasicGetOptions, ) -> impl Future<Item = BasicGetMessage, Error = Error> + Send + 'static

gets a message

Source

pub fn queue_purge( &self, queue_name: &str, options: QueuePurgeOptions, ) -> impl Future<Item = (), Error = Error> + Send + 'static

Purge a queue.

This method removes all messages from a queue which are not awaiting acknowledgment.

Source

pub fn queue_delete( &self, queue_name: &str, options: QueueDeleteOptions, ) -> impl Future<Item = (), Error = Error> + Send + 'static

Delete a queue.

This method deletes a queue. When a queue is deleted any pending messages are sent to a dead-letter queue if this is defined in the server configuration, and all consumers on the queue are cancelled.

If if_unused is set, the server will only delete the queue if it has no consumers. If the queue has consumers the server does not delete it but raises a channel exception instead.

If if_empty is set, the server will only delete the queue if it has no messages.

Source

pub fn close( &self, code: u16, message: &str, ) -> impl Future<Item = (), Error = Error> + Send + 'static

closes the channel

Source

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

ack a channel close

Source

pub fn channel_flow( &self, options: ChannelFlowOptions, ) -> impl Future<Item = (), Error = Error> + Send + 'static

update a channel flow

Source

pub fn channel_flow_ok( &self, options: ChannelFlowOptions, ) -> impl Future<Item = (), Error = Error> + Send + 'static

ack an update to a channel flow

Source

pub fn wait_for_answer<Finished>( tr: &mut AMQPTransport<T>, request_id: u64, finished: &Finished, ) -> Result<Async<Option<u64>>, Error>
where Finished: 'static + Send + Fn(&mut Connection, u64) -> Result<Async<Option<u64>>, Error>,

internal method to wait until a request succeeds

Trait Implementations§

Source§

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

Source§

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

Returns a duplicate 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 Channel<T>

§

impl<T> !RefUnwindSafe for Channel<T>

§

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

§

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

§

impl<T> Unpin for Channel<T>

§

impl<T> !UnwindSafe for Channel<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§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<T> Erased for T