<commit_before>stomp-rs ![Travis CI Build Status](https://api.travis-ci.org/zslayton/stomp-rs.png?branch=master)
=====
`stomp-rs` provides a full [STOMP](http://stomp.github.io/stomp-specification-1.2.html) 1.2 client implementation for the [Rust programming language](http://www.rust-lang.org/). This allows programs written in Rust to interact with message queueing services like [ActiveMQ](http://activemq.apache.org/) and [RabbitMQ](http://www.rabbitmq.com/).

- [x] Connect
- [x] Subscribe
- [x] Send
- [x] Acknowledge (Auto/Client/ClientIndividual)
- [x] Transactions
- [x] Receipts
- [x] Disconnect
- [x] Heartbeats

The APIs for `stomp-rs` are not yet stable and are likely to fluctuate before v1.0.

## Examples
### Connect / Subscribe / Send
```rust
extern crate stomp;
use stomp::frame::Frame;
use stomp::subscription::AckOrNack::{self, Ack};
use stomp::subscription::AckMode::Client;
use stomp::subscription::MessageHandler;

// Create a struct to hold any state you'd like manage
struct ExampleMessageHandler {
  message_count : u64
}

// Implement the `MessageHandler` trait for your struct
impl MessageHandler for ExampleMessageHandler {
  fn on_message(&mut self, frame: &Frame) -> AckOrNack {
    self.message_count += 1;
    println!("Received message #{}:\n{}", self.message_count, frame);
    Ack
  }
}

fn main() {
  let mut session = match stomp::connect("127.0.0.1", 61613) {
    Ok(session)  => session,
    Err(error) => panic!("Could not connect to the server: {}", error)
  };
  
  let topic = "/topic/messages";
  let message_handler = ExampleMessageHandler{message_count: 0u64};
  session.subscribe(topic, Client, message_handler); // 'client' acknowledgement mode
  
  // Send arbitrary bytes with a specified MIME type
  session.send_bytes(topic, "text/plain", "Animal".as_bytes());
  
  // Send UTF-8 text with an assumed MIME type of 'text/plain'
  session.send_text(topic, "Vegetable");
  session.send_text(topic, "Mineral");
  
  session.listen(); // Loops infinitely, awaiting messages

  session.disconnect();
}
```<commit_msg>Updated README to use closure in subscription<commit_after>stomp-rs ![Travis CI Build Status](https://api.travis-ci.org/zslayton/stomp-rs.png?branch=master)
=====
`stomp-rs` provides a full [STOMP](http://stomp.github.io/stomp-specification-1.2.html) 1.2 client implementation for the [Rust programming language](http://www.rust-lang.org/). This allows programs written in Rust to interact with message queueing services like [ActiveMQ](http://activemq.apache.org/) and [RabbitMQ](http://www.rabbitmq.com/).

- [x] Connect
- [x] Subscribe
- [x] Send
- [x] Acknowledge (Auto/Client/ClientIndividual)
- [x] Transactions
- [x] Receipts
- [x] Disconnect
- [x] Heartbeats

The APIs for `stomp-rs` are not yet stable and are likely to fluctuate before v1.0.

## Examples
### Connect / Subscribe / Send
```rust
extern crate stomp;
use stomp::frame::Frame;
use stomp::subscription::AckOrNack::{self, Ack};
use stomp::subscription::AckMode::Client;
use stomp::subscription::MessageHandler;

fn main() {
  let mut session = match stomp::connect("127.0.0.1", 61613) {
    Ok(session)  => session,
    Err(error) => panic!("Could not connect to the server: {}", error)
  };
  
  let topic = "/topic/messages";
  let mut message_count : u64 = 0;
  session.subscribe(topic, Client, |&mut: frame: &Frame|{ // 'client' acknowledgement mode
    message_count += 1;
    println!("Received message #{}:\n{}", message_count, frame);
    Ack
  });
  
  // Send arbitrary bytes with a specified MIME type
  session.send_bytes(topic, "text/plain", "Animal".as_bytes());
  
  // Send UTF-8 text with an assumed MIME type of 'text/plain'
  session.send_text(topic, "Vegetable");
  session.send_text(topic, "Mineral");
  
  session.listen(); // Loops infinitely, awaiting messages

  session.disconnect();
}
```
{'fraction_non_alphanumeric': 0.14964925954793454, 'fraction_numerical': 0.011951156144453105, 'mean_word_length': 4.407303370786517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4833192', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1256, 'n_words': 346}