break chunks into lines before adding them

master
rascul 2 years ago
parent 6e03d29f85
commit 1d6ddaa6c4

@ -52,7 +52,7 @@ pub fn parse_log(raw: &Vec<u8>) -> Result<Value> {
return Err("chunk size too small".into());
}
let (delta, size) = {
let (mut delta, size) = {
if let Ok((delta, size)) = chunk32(&chunk) {
(delta, size)
} else {
@ -79,10 +79,13 @@ pub fn parse_log(raw: &Vec<u8>) -> Result<Value> {
let text: String = String::from_utf8_lossy(&text_chunk).into();
let text: String = convert_escaped(&text)?;
let mut bm: Map<String, Value> = Map::new();
bm.insert("delta".into(), delta.into());
bm.insert("text".into(), text.into());
chunks.push(bm);
for line in text.lines() {
let mut map: Map<String, Value> = Map::new();
map.insert("delta".into(), delta.into());
map.insert("text".into(), line.trim().into());
chunks.push(map);
delta = 0;
}
}
Ok(chunks.into())

Loading…
Cancel
Save