The documents of one vector: its statement, then each record line.
(dir: &Path, vector: &Value)
| 66 | |
| 67 | /// The documents of one vector: its statement, then each record line. |
| 68 | fn documents(dir: &Path, vector: &Value) -> Vec<(String, Vec<u8>, bool)> { |
| 69 | let mut docs = Vec::new(); |
| 70 | let file = vector["file"].as_str().expect("vector names a file"); |
| 71 | docs.push((file.to_owned(), read(&dir.join(file)), false)); |
| 72 | if let Some(records) = vector["records"].as_str() { |
| 73 | let bytes = read(&dir.join(records)); |
| 74 | for (n, line) in bytes.split(|b| *b == b'\n').enumerate() { |
| 75 | if !line.is_empty() { |
| 76 | docs.push((format!("{records}:{}", n + 1), line.to_vec(), true)); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | docs |
| 81 | } |
| 82 | |
| 83 | /// `Ok(true)` when admitted and canonical, `Ok(false)` when admitted but not |
| 84 | /// canonical, and the refusal otherwise. |
no test coverage detected