Struct kparse::Track

source ·
pub struct Track;
Expand description

Central struct for tracking.

  • Create a TrackProvider with Track::new_tracker()

  • Create a matching span with new_span(). Switches between debug and release mode, and tracking is only active in debug mode.

  • Create a SourceStr/SourceBytes for row/column information.

  • Call the actual tracking functions:

    • Track.enter(), Track.ok(), Track.err(), …

Implementations§

source§

impl Track

source

pub fn new_tracker<C, I>() -> StdTracker<C, I>where C: Code, I: Clone + Debug + AsBytes + InputTake + InputLength + InputIter,

Provider/Container for tracking data.

source

pub fn new_span<'s, C, I>( provider: &'s impl TrackProvider<C, I>, text: I ) -> LocatedSpan<I, DynTrackProvider<'s, C, I>>where C: Code, I: Clone + Debug + AsBytes + InputTake + InputLength + InputIter + 's,

Create a tracking span for the given text and TrackProvider.

source

pub fn source_str(text: &str) -> SourceStr<'_>

Create a source text map for the given text.

source

pub fn source_bytes(text: &[u8]) -> SourceBytes<'_>

Create a source text map for the given text.

source

pub fn ok<C, I, O, E>( &self, rest: I, input: I, value: O ) -> Result<(I, O), Err<E>>where C: Code, I: Clone + Debug + TrackedSpan<C> + InputTake + InputLength + InputIter, E: KParseError<C, I> + Debug,

Creates an Ok() Result from the parameters and tracks the result.

source

pub fn err<C, I, O, E>( &self, err: E ) -> Result<(I, O), Err<<E as ErrOrNomErr>::WrappedError>>where C: Code, I: Clone + Debug + TrackedSpan<C> + InputTake + InputLength + InputIter, E: KParseError<C, I> + ErrOrNomErr + Debug,

Tracks the error and creates a Result.

source

pub fn ok_section<C, I>(&self, rest: I, input: I)where C: Code, I: TrackedSpan<C>,

When multiple Context.enter() calls are used within one function (to denote some separation), this can be used to exit such a compartment with an ok track.

source

pub fn err_section<C, I, E>(&self, err: &E)where C: Code, I: Clone + Debug + TrackedSpan<C> + InputTake + InputLength + InputIter, E: KParseError<C, I> + Debug,

When multiple Context.enter() calls are used within one function (to denote some separation), this can be used to exit such a compartment with an ok track.

source

pub fn enter<C, I>(&self, func: C, span: I)where C: Code, I: TrackedSpan<C>,

Enter a parser function.

source

pub fn debug<C, I>(&self, span: I, debug: String)where C: Code, I: TrackedSpan<C>,

Track some debug info.

source

pub fn info<C, I>(&self, span: I, info: &'static str)where C: Code, I: TrackedSpan<C>,

Track some other info.

source

pub fn warn<C, I>(&self, span: I, warn: &'static str)where C: Code, I: TrackedSpan<C>,

Track some warning.

Auto Trait Implementations§

§

impl RefUnwindSafe for Track

§

impl Send for Track

§

impl Sync for Track

§

impl Unpin for Track

§

impl UnwindSafe for Track

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.