Skip to main content

ExtractionTracker

Struct ExtractionTracker 

Source
pub struct ExtractionTracker { /* private fields */ }
Expand description

Mutable accounting state owned by one artifact-extractor invocation.

Implementations§

Source§

impl ExtractionTracker

Source

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.

Source

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.

Source

pub fn budgets(&self) -> &ExtractionBudgets

Returns the effective limits for this invocation.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn bounded_json_writer(&self) -> BoundedJsonWriter

Creates a JSON writer that refuses the first byte beyond the output ceiling.

Source

pub fn output_limit_error( &self, writer: &BoundedJsonWriter, ) -> Option<ExtractionLimitExceeded>

Converts an output-writer overflow into the invocation’s typed limit error.

Trait Implementations§

Source§

impl Debug for ExtractionTracker

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more