Skip to main content

acta/validate/
options.rs

1use crate::limits::Limits;
2
3/// The amount of an Acta file validation decodes.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum ValidationLevel {
6    /// Validate framing, schema metadata, and data-frame metadata only.
7    Structural,
8    /// Decode every complete data block and verify its logical invariants.
9    Full,
10}
11
12/// Options controlling Acta validation.
13///
14/// The fields are private so new validation controls can be added without
15/// exposing an unvalidated configuration structure.
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub struct ValidationOptions {
18    level: ValidationLevel,
19    limits: Limits,
20}
21
22impl ValidationOptions {
23    /// Return these options with the requested validation level.
24    pub fn with_level(mut self, level: ValidationLevel) -> Self {
25        self.level = level;
26        self
27    }
28
29    /// Return these options with caller-supplied resource limits.
30    pub fn with_limits(mut self, limits: Limits) -> Self {
31        self.limits = limits;
32        self
33    }
34
35    /// The selected validation level.
36    pub fn level(&self) -> ValidationLevel {
37        self.level
38    }
39
40    /// The resource limits applied during validation.
41    pub fn limits(&self) -> Limits {
42        self.limits
43    }
44}
45
46impl Default for ValidationOptions {
47    fn default() -> Self {
48        Self {
49            level: ValidationLevel::Structural,
50            limits: Limits::default(),
51        }
52    }
53}