pub struct AntReader<R: Read> {
pub manifest: Manifest,
pub verified: bool,
pub version: FormatVersion,
pub minor_ahead: bool,
/* private fields */
}Expand description
Streaming .ant reader. Yields records after validating the
manifest; reading through to the trailer verifies counts + hash and
sets AntReader::verified.
§Example
Read back a stream, one record at a time. The reader hashes every
line as it goes; when AntReader::next_record returns Ok(None)
the trailer’s sha256 and per-kind counts have been checked against
what was actually read:
use antares_format::{AntReader, AntRecord, AntWriter, Manifest, FORMAT_VERSION};
let mut reader = AntReader::new(bytes.as_slice())?;
assert_eq!(reader.manifest.format, "antares");
let mut records = 0;
while let Some(record) = reader.next_record()? {
match record {
AntRecord::Evidence { data } => assert_eq!(data.content, "example content"),
other => panic!("unexpected record: {other:?}"),
}
records += 1;
}
// `Ok(None)` means the trailer was reached AND verified: its hash
// and counts matched the records streamed above.
assert!(reader.verified);
assert_eq!(records, 1);Fields§
§manifest: ManifestThe manifest, validated during AntReader::new.
verified: boolSet once the trailer was seen and verified.
version: FormatVersionVersion parsed from the manifest. Same major as this build, or
new would have refused the file.
minor_ahead: boolThe file was written by a NEWER minor than this build. Readable by policy (minors are additive-only), but it may carry record kinds this build skipped — a caller that reports completeness to a user should say so.