A crate to parse and emit BR Code.
toml
[dependencies]
brcode = "0.1.0"
Parse String ```rust use brcode::{ from_str, parse::Data };
fn main() { let code = "00020104141234567890123426580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-42665544000027300012BR.COM.OUTRO011001234567895204000053039865406123.455802BR5917NOME DO RECEBEDOR6008BRASILIA61087007490062190515RP12345678-201980390012BR.COM.OUTRO01190123.ABCD.3456.WXYZ6304AD38";
assert_eq!(from_str(code), expected());
}
fn expected() -> Vec<(usize, Data)> { vec![ (0, Data::Single("01".tostring())), (4, Data::Single("12345678901234".tostring())), (26, Data::Vector(vec![ (0, Data::Single("BR.GOV.BCB.PIX".tostring())), (1, Data::Single("123e4567-e12b-12d1-a456-426655440000".tostring()))])), (27, Data::Vector(vec![ (0, Data::Single("BR.COM.OUTRO".tostring())), (1, Data::Single("0123456789".tostring()))])), (52, Data::Single("0000".tostring())), (53, Data::Single("986".tostring())), (54, Data::Single("123.45".tostring())), (58, Data::Single("BR".tostring())), (59, Data::Single("NOME DO RECEBEDOR".tostring())), (60, Data::Single("BRASILIA".tostring())), (61, Data::Single("70074900".tostring())), (62, Data::Vector(vec![ (5, Data::Single("RP12345678-2019".tostring()))])), (80, Data::Vector(vec![( 0, Data::Single("BR.COM.OUTRO".tostring())), (1, Data::Single("0123.ABCD.3456.WXYZ".tostring()))])), (63, Data::Single("AD38".to_string()))] } ```
from_str in benches/parse.rs
time: [16.200 us 16.251 us 16.319 us]
BrCode
struct;BrCode
struct;