<commit_before>//! itchy - a nom-based parser for the NASDAQ ITCH protocol 5.0
//!
//! It aims to sensibly handle the whole protocol.
//! It is zero-allocation and pretty fast. It will process
//! several million messages per second on a decent CPU.
//!
//! Typical usage:
//!
//! ```ignore
//! extern crate itchy;
//!
//! let stream = itchy::MessageStream::from_file("/path/to/file.itch").unwrap();
//! for msg in stream {
//!     println!("{:?}", msg.unwrap())
//! }
//! ```
//!
//! The protocol specification can be found on the [NASDAQ website](http://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/NQTVITCHSpecification_5.0.pdf)

#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate nom;
extern crate flate2;
extern crate arrayvec;
extern crate decimal;

use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use std::fmt;
pub use decimal::d128;

use flate2::read::GzDecoder;
use nom::{be_u8, be_u16, be_u32, be_u64, IResult, Needed};
pub use arrayvec::ArrayString;

/// Stack-allocated string of size 4 bytes (re-exported from `arrayvec`)
pub type ArrayString4 = ArrayString<[u8; 4]>;

/// Stack-allocated string of size 8 bytes (re-exported from `arrayvec`)
pub type ArrayString8 = ArrayString<[u8; 8]>;

use errors::*;
pub use enums::*;
use enums::parse_issue_subtype;

const BUFSIZE: usize = 8 * 1024;

mod enums;

#[allow(unused_doc_comment)]
pub mod errors {
    error_chain!{
        foreign_links {
            Io(::std::io::Error);
            Nom(::nom::Err);
        }
    }
}

/// Represents an iterable stream of ITCH protocol messages
pub struct MessageStream<R> {
    reader: R,
    buffer: Box<[u8; BUFSIZE]>,
    bufstart: usize,
    bufend: usize,
    bytes_read: usize,
    read_calls: u32,
    message_ct: u32,
    in_error_state: bool,<commit_msg>remove allow unused doc comment<commit_after>//! itchy - a nom-based parser for the NASDAQ ITCH protocol 5.0
//!
//! It aims to sensibly handle the whole protocol.
//! It is zero-allocation and pretty fast. It will process
//! several million messages per second on a decent CPU.
//!
//! Typical usage:
//!
//! ```ignore
//! extern crate itchy;
//!
//! let stream = itchy::MessageStream::from_file("/path/to/file.itch").unwrap();
//! for msg in stream {
//!     println!("{:?}", msg.unwrap())
//! }
//! ```
//!
//! The protocol specification can be found on the [NASDAQ website](http://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/NQTVITCHSpecification_5.0.pdf)

#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate nom;
extern crate flate2;
extern crate arrayvec;
extern crate decimal;

use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use std::fmt;
pub use decimal::d128;

use flate2::read::GzDecoder;
use nom::{be_u8, be_u16, be_u32, be_u64, IResult, Needed};
pub use arrayvec::ArrayString;

/// Stack-allocated string of size 4 bytes (re-exported from `arrayvec`)
pub type ArrayString4 = ArrayString<[u8; 4]>;

/// Stack-allocated string of size 8 bytes (re-exported from `arrayvec`)
pub type ArrayString8 = ArrayString<[u8; 8]>;

use errors::*;
pub use enums::*;
use enums::parse_issue_subtype;

const BUFSIZE: usize = 8 * 1024;

mod enums;

pub mod errors {
    error_chain!{
        foreign_links {
            Io(::std::io::Error);
            Nom(::nom::Err);
        }
    }
}

/// Represents an iterable stream of ITCH protocol messages
pub struct MessageStream<R> {
    reader: R,
    buffer: Box<[u8; BUFSIZE]>,
    bufstart: usize,
    bufend: usize,
    bytes_read: usize,
    read_calls: u32,
    message_ct: u32,
    in_error_state: bool,
{'fraction_non_alphanumeric': 0.15048143053645116, 'fraction_numerical': 0.018707015130674003, 'mean_word_length': 3.7467362924281984, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, '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': '5670243', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1240, 'n_words': 362}