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
impl Connection
Sourcepub async fn open(args: &OpenConnectionArguments) -> Result<Connection, Error>
pub async fn open(args: &OpenConnectionArguments) -> Result<Connection, Error>
Sourcepub fn connection_name(&self) -> &str
pub fn connection_name(&self) -> &str
Get connection name.
Sourcepub fn channel_max(&self) -> u16
pub fn channel_max(&self) -> u16
Get the maximum total number of channels of the connection.
Sourcepub fn frame_max(&self) -> u32
pub fn frame_max(&self) -> u32
Get The largest frame size that the client and server will use for the connection.
Sourcepub fn server_properties(&self) -> &ServerProperties
pub fn server_properties(&self) -> &ServerProperties
Get the server propertities reported by server.
Sourcepub async fn register_callback<F>(&self, callback: F) -> Result<(), Error>where
F: ConnectionCallback + Send + 'static,
pub async fn register_callback<F>(&self, callback: F) -> Result<(), Error>where
F: ConnectionCallback + Send + 'static,
Sourcepub async fn blocked(&self, reason: &str) -> Result<(), Error>
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.
Sourcepub async fn unblocked(&self) -> Result<(), Error>
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.
Sourcepub async fn close(self) -> Result<(), Error>
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.
Sourcepub async fn listen_network_io_failure(&self) -> bool
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
impl Clone for Connection
Source§fn clone(&self) -> Connection
fn clone(&self) -> Connection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more