1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! # Stomp lib
//!
//! ## Usage
//! Creating a client:
//! ```no_run
//! use stomp_rs::client::{Client, ClientBuilder};
//! use tokio::net::TcpStream;
//! use tokio::sync::mpsc::channel;
//! use std::error::Error;
//!
//! async fn connect() -> Result<Client, Box<dyn Error>> {
//!   Client::connect(
//!       ClientBuilder::new("127.0.0.1:61613")
//!   ).await
//! }
//! ```
//!
//! Emitting a new frame:
//!
//! ```no_run
//! use stomp_rs::protocol::frame::Send;
//! use stomp_rs::client::Client;
//! use std::error::Error;;
//!
//! async fn send_example(client: &Client) -> Result<(), Box<dyn Error>> {
//!   client.send(
//!       Send::new("/topic/test")
//!         .body("test-message")
//!   ).await
//! }
//! ```
//!
//! Subscribe:
//! ```no_run
//! use stomp_rs::client::Client;
//! use stomp_rs::protocol::frame::Subscribe;
//! use tokio::sync::mpsc::{channel, Sender, Receiver};
//! use std::error::Error;
//! use stomp_rs::protocol::{Frame, ServerCommand};
//! use std::future::Future;
//! use std::sync::Arc;
//!
//! async fn subscribe_example(client: Arc<Client>)-> Result<(), Box<dyn Error>> {
//!   let (sender, mut receiver): (Sender<Frame<ServerCommand>>, Receiver<Frame<ServerCommand>>) = channel(16);
//!
//!   let subscriber_client = Arc::clone(&client);
//!   tokio::spawn(async move {
//!     match receiver.recv().await {
//!       Some(frame) => {
//!         /* process frame */
//!
//!         // Send ack to server
//!         subscriber_client.ack(frame.ack().unwrap())
//!             .await;
//!       }
//!       None => { }
//!     }
//!   });
//!
//!   client.subscribe(
//!       Subscribe::new_with_random_id("/topic/test"),
//!       sender
//!   ).await
//! }
pub mod client;
pub mod connection;
pub mod protocol;