[][src]Function sorer::parsers::parse_line_with_schema

pub fn parse_line_with_schema(
    i: &[u8],
    schema: &Vec<DataType>
) -> Option<Vec<Data>>

Parses a row of SoR data, i (as a &[u8]), into a Option<Vec<Data>>, returning Some if the data types in i matches the schema. If the data types match, but i contains fewer fields than schema, than Data::Null is inserted. If the row has more fields than schema, then the extra fields are discarded.

Further information on how parsing with schemas can be found here and here


use sorer::schema::DataType;
use sorer::parsers::parse_line_with_schema;
use sorer::dataframe::Data;

let i = b"< 1 > < hi >";
let s = vec![DataType::Bool, DataType::String];

           parse_line_with_schema(i, &s));


This function calls std::str::from_utf8_unchecked, meaning that it does not check that the bytes passed to it are valid UTF-8. If this constraint is violated, undefined behavior results, as the rest of Rust assumes that &strs are valid UTF-8.

Since SoR files are guaranteed to only contain valid C++ strings, and thus only valid utf-8, then this constraint only applies to consumers of the crate and not users of the SoRer executable.