pub struct ExtractionTracker { /* private fields */ }Expand description
Mutable accounting state owned by one artifact-extractor invocation.
Implementations§
Source§impl ExtractionTracker
impl ExtractionTracker
Sourcepub fn new(
artifact: impl Into<String>,
extractor: impl Into<String>,
budgets: &ExtractionBudgets,
) -> Self
pub fn new( artifact: impl Into<String>, extractor: impl Into<String>, budgets: &ExtractionBudgets, ) -> Self
Starts a fresh tracker for one physical artifact and one extractor.
Sourcepub fn with_clock(
artifact: impl Into<String>,
extractor: impl Into<String>,
budgets: &ExtractionBudgets,
clock: Box<dyn ExtractionClock>,
) -> Self
pub fn with_clock( artifact: impl Into<String>, extractor: impl Into<String>, budgets: &ExtractionBudgets, clock: Box<dyn ExtractionClock>, ) -> Self
Starts a tracker with an injected monotonic clock.
Sourcepub fn budgets(&self) -> &ExtractionBudgets
pub fn budgets(&self) -> &ExtractionBudgets
Returns the effective limits for this invocation.
Sourcepub fn check_input_bytes(
&self,
observed: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn check_input_bytes( &self, observed: u64, ) -> Result<(), ExtractionLimitExceeded>
Checks source bytes before parsing or decoding them.
§Errors
Returns ExtractionLimitExceeded when observed exceeds the input-byte maximum.
Sourcepub fn check_string_bytes(
&self,
observed: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn check_string_bytes( &self, observed: u64, ) -> Result<(), ExtractionLimitExceeded>
Checks one string token before a structured parser allocates it.
This does not charge the accumulated output counter; callers must still charge retained values immediately before materializing extraction output.
§Errors
Returns ExtractionLimitExceeded when observed exceeds the per-string maximum.
Sourcepub fn check_identifier_bytes(
&self,
observed: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn check_identifier_bytes( &self, observed: u64, ) -> Result<(), ExtractionLimitExceeded>
Checks one identifier token before a structured parser allocates it.
§Errors
Returns ExtractionLimitExceeded when observed exceeds the per-identifier maximum.
Sourcepub fn check_accumulated_string_bytes(
&self,
observed: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn check_accumulated_string_bytes( &self, observed: u64, ) -> Result<(), ExtractionLimitExceeded>
Checks lexical string accumulation before structured parsing.
§Errors
Returns ExtractionLimitExceeded when the observed lexical bytes exceed the accumulated
output-string maximum.
Sourcepub fn charge_work(
&mut self,
amount: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn charge_work( &mut self, amount: u64, ) -> Result<(), ExtractionLimitExceeded>
Charges deterministic work before the associated allocation or traversal.
§Errors
Returns ExtractionLimitExceeded before accepting work beyond the configured maximum or
when the sampled structured deadline has elapsed.
Sourcepub fn check_work_units(
&self,
observed: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn check_work_units( &self, observed: u64, ) -> Result<(), ExtractionLimitExceeded>
Checks a conservative prospective work count without accepting it.
§Errors
Returns ExtractionLimitExceeded when observed exceeds the work maximum.
Sourcepub fn charge_tree_sitter_node(
&mut self,
depth: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn charge_tree_sitter_node( &mut self, depth: u64, ) -> Result<(), ExtractionLimitExceeded>
Charges one Tree-sitter node before visiting its children.
§Errors
Returns ExtractionLimitExceeded for excessive AST depth, node count, or sampled
Tree-sitter wall time.
Sourcepub fn charge_observation(
&mut self,
amount: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn charge_observation( &mut self, amount: u64, ) -> Result<(), ExtractionLimitExceeded>
Charges observations before inserting them into a collection.
§Errors
Returns ExtractionLimitExceeded before the observation maximum is exceeded.
Sourcepub fn check_observations(
&self,
observed: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn check_observations( &self, observed: u64, ) -> Result<(), ExtractionLimitExceeded>
Checks a conservative prospective observation count without accepting materialization.
§Errors
Returns ExtractionLimitExceeded when observed exceeds the observation maximum.
Sourcepub fn ensure_observations(
&mut self,
minimum: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn ensure_observations( &mut self, minimum: u64, ) -> Result<(), ExtractionLimitExceeded>
Ensures at least the supplied number of output observations has been charged.
§Errors
Returns ExtractionLimitExceeded when the minimum would exceed the observation maximum.
Sourcepub fn charge_string(
&mut self,
value: &str,
) -> Result<(), ExtractionLimitExceeded>
pub fn charge_string( &mut self, value: &str, ) -> Result<(), ExtractionLimitExceeded>
Charges extracted string bytes and validates the per-value ceiling before cloning.
§Errors
Returns ExtractionLimitExceeded for an oversized value or accumulated string total.
Sourcepub fn charge_portable_path(
&mut self,
value: &str,
) -> Result<(), ExtractionLimitExceeded>
pub fn charge_portable_path( &mut self, value: &str, ) -> Result<(), ExtractionLimitExceeded>
Charges a portable path before it is materialized.
§Errors
Returns ExtractionLimitExceeded for an oversized path or accumulated string total.
Sourcepub fn charge_identifier(
&mut self,
value: &str,
) -> Result<(), ExtractionLimitExceeded>
pub fn charge_identifier( &mut self, value: &str, ) -> Result<(), ExtractionLimitExceeded>
Charges an identifier before it is materialized.
§Errors
Returns ExtractionLimitExceeded for an oversized identifier or accumulated string
total.
Sourcepub fn charge_identifier_bytes(
&mut self,
bytes: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn charge_identifier_bytes( &mut self, bytes: u64, ) -> Result<(), ExtractionLimitExceeded>
Charges a prospective identifier byte length before allocating its owned value.
§Errors
Returns ExtractionLimitExceeded before the identifier or accumulated string maximum
is exceeded.
Sourcepub fn check_structural_depth(
&self,
depth: u64,
) -> Result<(), ExtractionLimitExceeded>
pub fn check_structural_depth( &self, depth: u64, ) -> Result<(), ExtractionLimitExceeded>
Checks structured nesting before entering the next level.
§Errors
Returns ExtractionLimitExceeded when depth exceeds the structural maximum.
Sourcepub fn check_ast_depth(&self, depth: u64) -> Result<(), ExtractionLimitExceeded>
pub fn check_ast_depth(&self, depth: u64) -> Result<(), ExtractionLimitExceeded>
Checks AST nesting before visiting a syntax node.
§Errors
Returns ExtractionLimitExceeded when depth exceeds the AST maximum.
Sourcepub fn check_structured_time(&self) -> Result<(), ExtractionLimitExceeded>
pub fn check_structured_time(&self) -> Result<(), ExtractionLimitExceeded>
Checks structured wall time immediately, including parser callbacks.
§Errors
Returns ExtractionLimitExceeded after the structured wall-time deadline.
Sourcepub fn check_tree_sitter_time(&self) -> Result<(), ExtractionLimitExceeded>
pub fn check_tree_sitter_time(&self) -> Result<(), ExtractionLimitExceeded>
Checks Tree-sitter wall time immediately, including parser callbacks.
§Errors
Returns ExtractionLimitExceeded after the Tree-sitter wall-time deadline.
Sourcepub fn bounded_json_writer(&self) -> BoundedJsonWriter ⓘ
pub fn bounded_json_writer(&self) -> BoundedJsonWriter ⓘ
Creates a JSON writer that refuses the first byte beyond the output ceiling.
Sourcepub fn output_limit_error(
&self,
writer: &BoundedJsonWriter,
) -> Option<ExtractionLimitExceeded>
pub fn output_limit_error( &self, writer: &BoundedJsonWriter, ) -> Option<ExtractionLimitExceeded>
Converts an output-writer overflow into the invocation’s typed limit error.