1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// SPDX-License-Identifier: Apache-2.0
//! Provenance and exactness value types.
//!
//! [`Exactness`] classifies how an IR value relates to source bytes. Current
//! documents store exactness and source locations in
//! [`crate::annotations::Annotations`].
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
/// Source location for an entity's bytes.
///
/// `offset` is relative to `stream`; `tag` identifies the source record class
/// when known.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct Provenance {
/// Source container format.
pub format: String,
/// Named stream within the container (a decompressed entry name, or empty).
pub stream: String,
/// Byte offset of the record within `stream`.
pub offset: u64,
/// Source record/class name/tag, when the decoder can attribute one.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tag: Option<String>,
}
/// How an entity or field value was established from its source.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Exactness {
/// Read verbatim from the source stream with no transformation beyond
/// documented unit conversion.
ByteExact,
/// Computed deterministically from byte-exact inputs.
Derived,
/// Filled in from context or convention rather than an explicit source field.
Inferred,
/// Origin or trustworthiness could not be established.
Unknown,
}