Connection

Struct Connection 

Source
pub struct Connection { /* private fields */ }
Expand description

Type represents an connection.

See documentation of each method. See also documentation of module .

Implementations§

Source§

impl Connection

Source

pub async fn open(args: &OpenConnectionArguments) -> Result<Connection, Error>

Open and returns a new connection.

§Errors

Returns Err if any step goes wrong during openning an connection.

Source

pub fn connection_name(&self) -> &str

Get connection name.

Source

pub fn channel_max(&self) -> u16

Get the maximum total number of channels of the connection.

Source

pub fn frame_max(&self) -> u32

Get The largest frame size that the client and server will use for the connection.

Source

pub fn server_properties(&self) -> &ServerProperties

Get the server propertities reported by server.

Source

pub async fn register_callback<F>(&self, callback: F) -> Result<(), Error>
where F: ConnectionCallback + Send + 'static,

Register callbacks for handling asynchronous message from server for the connection.

User should always register callbacks. See callbacks documentation.

§Errors

Returns error if fail to send registration command. If returns Err, user can try again until registration succeed.

Source

pub fn is_open(&self) -> bool

Returns true if connection is open.

Source

pub fn heartbeat(&self) -> u16

Returns interval of heartbeat in seconds.

Source

pub async fn open_channel( &self, channel_id: Option<u16>, ) -> Result<Channel, Error>

Open and return a new AMQP channel.

channel_id range: 1 to 65535.

Automatically generate an id if input channel_id = None, otherwise, use the given input id.

§Errors

Returns error if the given channel_id is occupied, or any failure in resource allocation and communication with server.

Source

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

This method notify server that the connection has been blocked and does not accept new publishes.

§Errors

Returns error if fails to send indication to server.

Source

pub async fn unblocked(&self) -> Result<(), Error>

This method notify server that the connection has been unblocked and does not accept new publishes.

§Errors

Returns error if fails to send indication to server.

Source

pub async fn close(self) -> Result<(), Error>

Send request to server to close the connection.

To gracefully shutdown the connection, recommended to close the connection explicitly instead of relying on drop.

This method consume the connection, so even it may return error, connection will anyway be dropped.

§Errors

Returns error if any failure in communication with server.

Source

pub async fn listen_network_io_failure(&self) -> bool

Wait until the underlying network I/O failure occurs.

It will block the current async task. To handle it asynchronously, use tokio::spawn to run it in a seperate task.

§Returns

Return true if got notification due to network I/O failure, otherwise return false.

Trait Implementations§

Source§

impl Clone for Connection

Source§

fn clone(&self) -> Connection

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

impl Display for Connection

Source§

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

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<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.