pub fn record(input: &[u8]) -> IResult<&[u8], Record> {
    // TODO if the stream parser does not get all the header it fails .
    // like a default size of 10 doesnt for for a producer
    match warc_header(input) {
        IResult::Done(i, ((_name, _version), headers)) => {
            let length = headers.iter()
                .find(|&&(k, _v)| k == "Content-Length")
                .map(|&(_k, v)| v)
                .and_then(|l| l.parse::<usize>().ok())
                .unwrap_or(0);
            if length > i.len() {
                // Need to refill the buffer
                return IResult::Incomplete(Needed::Size(length - i.len()));
            } else {
                // It's already in the buffer
                return IResult::Done(&i[length..], // slide forward
                                     String::from_utf8_lossy(&i[0..length])
                                             .into_owned());
            }
        }
        IResult::Incomplete(a) => IResult::Incomplete(a),
        IResult::Error(a) => IResult::Error(a),
    }
}
/// Parses one record and returns an IResult from nom
///
/// IResult<&[u8], Record>
///
/// See records for processing more than one. The documentation is not displaying.
///
/// # Examples
/// ```ignore
///  extern crate warc_parser;
///  extern crate nom;
///  use nom::{IResult};
///  let parsed = warc_parser::record(&bbc);
///  match parsed{
///      IResult::Error(_) => assert!(false),
///      IResult::Incomplete(_) => assert!(false),
///      IResult::Done(i, entry) => {
///          let empty: Vec<u8> =  Vec::new();
///          assert_eq!(empty, i);
///          assert_eq!(13, entry.headers.len());
///      }
///  }
/// ```
Parses one record and returns an IResult from nom
IResult<&[u8], Record>

See records for processing more than one. The documentation is not displaying.
Parses one record and returns an IResult from nom IResult<& [ u8 ] Record > See records for processing more than one . The documentation is not displaying .
pub fn record(input: &[u8]) -> IResult<&[u8], Record> {
    // TODO if the stream parser does not get all the header it fails .
    // like a default size of 10 doesnt for for a producer
    match warc_header(input) {
        IResult::Done(i, ((_name, _version), headers)) => {
            let length = headers.iter()
                .find(|&&(k, _v)| k == "Content-Length")
                .map(|&(_k, v)| v)
                .and_then(|l| l.parse::<usize>().ok())
                .unwrap_or(0);
            if length > i.len() {
                // Need to refill the buffer
                return IResult::Incomplete(Needed::Size(length - i.len()));
            } else {
                // It's already in the buffer
                return IResult::Done(&i[length..], // slide forward
                                     String::from_utf8_lossy(&i[0..length])
                                             .into_owned());
            }
        }
        IResult::Incomplete(a) => IResult::Incomplete(a),
        IResult::Error(a) => IResult::Error(a),
    }
}
pub fn record ( input : & [ u8 ] ) -> IResult < & [ u8 ] , Record > { // TODO if the stream parser does not get all the header it fails . // like a default size of 10 doesnt for for a producer match warc_header ( input ) { IResult :: Done ( i , ( ( _name , _version ) , headers ) ) => { let length = headers . iter ( ) . find ( | & & ( k , _v ) | k == " " ) . map ( | & ( _k , v ) | v ) . and_then ( | l | l . parse :: < usize > ( ) . ok ( ) ) . unwrap_or ( 0 ) ; if length > i . len ( ) { // Need to refill the buffer return IResult :: Incomplete ( Needed :: Size ( length - i . len ( ) ) ) ; } else { // It's already in the buffer return IResult :: Done ( & i [ length .. ] , // slide forward String :: from_utf8_lossy ( & i [ 0 .. length ] ) . into_owned ( ) ) ; } } IResult :: Incomplete ( a ) => IResult :: Incomplete ( a ) , IResult :: Error ( a ) => IResult :: Error ( a ) , } }
Parses one record and returns an IResult from nom
IResult<&[u8], Record>
Parses one record and returns an IResult from nom IResult<& [ u8 ] Record >
input
&[u8]
input
&[u8]
examples
```ignore
extern crate warc_parser;
extern crate nom;
use nom::{IResult};
let parsed = warc_parser::record(&bbc);
match parsed{
IResult::Error(_) => assert!(false),
IResult::Incomplete(_) => assert!(false),
IResult::Done(i, entry) => {
let empty: Vec =  Vec::new();
assert_eq!(empty, i);
assert_eq!(13, entry.headers.len());
}
}
```
` ` ` ignore extern crate warc_parser ; extern crate nom ; use nom :: { IResult } ; let parsed = warc_parser :: record ( &bbc ) ; match parsed { IResult :: Error ( _ ) = > assert! ( false ) IResult :: Incomplete ( _ ) = > assert! ( false ) IResult :: Done ( i entry ) = > { let empty : Vec = Vec :: new () ; assert_eq! ( empty i ) ; assert_eq! ( 13 entry . headers . len () ) ; } } ` ` `