lapin-async

this library is meant for use in an event loop. The library exposes, through the Connection struct, a state machine you can drive through IO you manage.

Typically, your code would own the socket and buffers, and regularly pass the input and output buffers to the state machine so it receives messages and serializes new ones to send. You can then query the current state and see if it received new messages for the consumers.

Example

```rust use envlogger; use lapinasync as lapin; use log::info;

use crate::lapin::{ BasicProperties, Channel, Connection, ConnectionProperties, ConsumerSubscriber, message::Delivery, options::*, types::FieldTable, };

[derive(Clone,Debug)]

struct Subscriber { channel: Channel, }

impl ConsumerSubscriber for Subscriber { fn newdelivery(&self, delivery: Delivery) { self.channel.basicack(delivery.deliverytag, BasicAckOptions::default()).intoresult().expect("basicack"); } fn dropprefetched_messages(&self) {} fn cancel(&self) {} }

fn main() { env_logger::init();

let addr = std::env::var("AMQPADDR").unwraporelse(|| "amqp://127.0.0.1:5672/%2f".into()); let conn = Connection::connect(&addr, ConnectionProperties::default()).wait().expect("connection error");

info!("CONNECTED");

let channela = conn.createchannel().wait().expect("createchannel"); let channelb = conn.createchannel().wait().expect("createchannel");

channela.queuedeclare("hello", QueueDeclareOptions::default(), FieldTable::default()).wait().expect("queuedeclare"); channelb.queuedeclare("hello", QueueDeclareOptions::default(), FieldTable::default()).wait().expect("queuedeclare");

info!("will consume"); channelb.basicconsume("hello", "myconsumer", BasicConsumeOptions::default(), FieldTable::default(), Box::new(Subscriber { channel: channelb.clone() })).wait().expect("basic_consume");

let payload = b"Hello world!";

loop { channela.basicpublish("", "hello", BasicPublishOptions::default(), payload.tovec(), BasicProperties::default()).wait().expect("basicpublish"); } }

```