Struct lapin::Connection

source ·
pub struct Connection { /* private fields */ }
Expand description

A TCP connection to the AMQP server.

To connect to the server, one of the connect methods has to be called.

Afterwards, create a Channel by calling create_channel.

Also see the RabbitMQ documentation on connections.

Implementations§

source§

impl Connection

source

pub async fn connect( uri: &str, options: ConnectionProperties ) -> Result<Connection>

Connect to an AMQP Server.

The URI must be in the following format:

  • amqp://127.0.0.1:5672 will connect to the default virtual host /.
  • amqp://127.0.0.1:5672/ will connect to the virtual host "" (empty string).
  • amqp://127.0.0.1:5672/%2f will connect to the default virtual host /.

Note that the virtual host has to be escaped with URL encoding.

source

pub async fn connect_with_config( uri: &str, options: ConnectionProperties, config: OwnedTLSConfig ) -> Result<Connection>

Connect to an AMQP Server.

source

pub async fn connect_uri( uri: AMQPUri, options: ConnectionProperties ) -> Result<Connection>

Connect to an AMQP Server.

source

pub async fn connect_uri_with_config( uri: AMQPUri, options: ConnectionProperties, config: OwnedTLSConfig ) -> Result<Connection>

Connect to an AMQP Server

source

pub async fn create_channel(&self) -> Result<Channel>

Creates a new Channel on this connection.

This method is only successful if the client is connected. Otherwise, InvalidConnectionState error is returned.

source

pub async fn restore( &self, topology: TopologyDefinition ) -> Result<RestoredTopology>

Restore the specified topology

source

pub fn run(self) -> Result<()>

Block current thread while the connection is still active. This is useful when you only have a consumer and nothing else keeping your application “alive”.

source

pub fn on_error<E: FnMut(Error) + Send + 'static>(&self, handler: E)

source

pub fn configuration(&self) -> &Configuration

source

pub fn status(&self) -> &ConnectionStatus

source

pub async fn close(&self, reply_code: ReplyCode, reply_text: &str) -> Result<()>

Request a connection close.

This method is only successful if the connection is in the connected state, otherwise an InvalidConnectionState error is returned.

source

pub async fn block(&self, reason: &str) -> Result<()>

Block all consumers and publishers on this connection

source

pub async fn unblock(&self) -> Result<()>

Unblock all consumers and publishers on this connection

source

pub async fn update_secret(&self, new_secret: &str, reason: &str) -> Result<()>

Update the secret used by some authentication module such as OAuth2

source

pub async fn connector( uri: AMQPUri, connect: Box<dyn FnOnce(&AMQPUri) -> HandshakeResult + Send + Sync>, options: ConnectionProperties ) -> Result<Connection>

source

pub fn topology(&self) -> TopologyDefinition

Get the current topology

This includes exchanges, queues, bindings and consumers declared by this Connection

Trait Implementations§

source§

impl Debug for Connection

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

source§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more