MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / documents

Function documents

atomic-canonical/tests/conformance_corpus.rs:68–81  ·  view source on GitHub ↗

The documents of one vector: its statement, then each record line.

(dir: &Path, vector: &Value)

Source from the content-addressed store, hash-verified

66
67/// The documents of one vector: its statement, then each record line.
68fn 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.

Calls 4

readFunction · 0.70
as_strMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected