Struct metalmq_client::Client
source · pub struct Client {
pub connection_id: String,
pub event_stream: UnboundedReceiver<EventSignal>,
/* private fields */
}
Expand description
The AMQP client instance which reprensents an open connection.
Client
can be created with Client::connect
.
Usage
use metalmq_client::Client;
async fn connect() {
let mut client = Client::connect("localhost:5672", "guest", "guest").await.unwrap();
let mut channel = client.channel_open(1u16).await.unwrap();
// ...
channel.close().await.unwrap();
client.close().await.unwrap();
}
Fields§
§connection_id: String
§event_stream: UnboundedReceiver<EventSignal>
Implementations§
source§impl Client
impl Client
pub async fn connect(url: &str, username: &str, password: &str) -> Result<Client>
sourcepub async fn channel_open(&mut self, channel: ChannelNumber) -> Result<Channel>
pub async fn channel_open(&mut self, channel: ChannelNumber) -> Result<Channel>
Open a channel in the current connection.
sourcepub async fn receive_event(&mut self, timeout: Duration) -> Option<EventSignal>
pub async fn receive_event(&mut self, timeout: Duration) -> Option<EventSignal>
Convenient function for listening EventSignal
with timeout.