Struct Recoverable

Source
pub struct Recoverable<I, E>
where I: Stream,
{ /* private fields */ }
Available on crate features unstable-recover and std only.
Expand description

Allow recovering from parse errors, capturing them as the parser continues

Generally, this will be used indirectly via RecoverableParser::recoverable_parse.

Implementations§

Source§

impl<I, E> Recoverable<I, E>
where I: Stream,

Source

pub fn new(input: I) -> Self

Track recoverable errors with the stream

Source

pub fn unrecoverable(input: I) -> Self

Act as a normal stream

Source

pub fn into_parts(self) -> (I, Vec<E>)

Access the current input and errors

Trait Implementations§

Source§

impl<I, E> AsBStr for Recoverable<I, E>
where I: Stream + AsBStr,

Source§

fn as_bstr(&self) -> &[u8]

Casts the input type to a byte slice
Source§

impl<I, E> AsBytes for Recoverable<I, E>
where I: Stream + AsBytes,

Source§

fn as_bytes(&self) -> &[u8]

Casts the input type to a byte slice
Source§

impl<I, E> AsRef<I> for Recoverable<I, E>
where I: Stream,

Source§

fn as_ref(&self) -> &I

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<I, E: Clone> Clone for Recoverable<I, E>
where I: Stream + Clone,

Source§

fn clone(&self) -> Recoverable<I, E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I, E, U> Compare<U> for Recoverable<I, E>
where I: Stream + Compare<U>,

Source§

fn compare(&self, other: U) -> CompareResult

Compares self to another value for equality
Source§

impl<I, E: Debug> Debug for Recoverable<I, E>
where I: Stream + Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<I, E> Default for Recoverable<I, E>
where I: Default + Stream,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<I, E> Deref for Recoverable<I, E>
where I: Stream,

Source§

type Target = I

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<I, E> Display for Recoverable<I, E>
where I: Stream + Display,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<I, E, T> FindSlice<T> for Recoverable<I, E>
where I: Stream + FindSlice<T>,

Source§

fn find_slice(&self, substr: T) -> Option<Range<usize>>

Returns the offset of the slice if it is found
Source§

impl<I, E> Location for Recoverable<I, E>
where I: Location + Stream,

Source§

fn previous_token_end(&self) -> usize

Previous token’s end offset
Source§

fn current_token_start(&self) -> usize

Current token’s start offset
Source§

impl<I, E> Offset<<Recoverable<I, E> as Stream>::Checkpoint> for Recoverable<I, E>
where I: Stream, E: Debug,

Source§

fn offset_from( &self, other: &<Recoverable<I, E> as Stream>::Checkpoint, ) -> usize

Offset between the first byte of start and the first byte of selfa Read more
Source§

impl<I, E> Offset for Recoverable<I, E>
where I: Stream, E: Debug,

Source§

fn offset_from(&self, other: &Self) -> usize

Offset between the first byte of start and the first byte of selfa Read more
Source§

impl<I, E, R> Recover<E> for Recoverable<I, R>
where I: Stream, R: FromRecoverableError<Self, E> + Debug, E: ParserError<Self>,

Source§

fn is_recovery_supported() -> bool

Report whether the Stream can save off errors for recovery

Source§

fn record_err( &mut self, token_start: &Self::Checkpoint, err_start: &Self::Checkpoint, err: E, ) -> Result<(), E>

Capture a top-level error Read more
Source§

impl<I, E> SliceLen for Recoverable<I, E>
where I: SliceLen + Stream,

Source§

fn slice_len(&self) -> usize

Calculates the input length, as indicated by its name, and the name of the trait itself
Source§

impl<I, E: Debug> Stream for Recoverable<I, E>
where I: Stream,

Source§

type Token = <I as Stream>::Token

The smallest unit being parsed Read more
Source§

type Slice = <I as Stream>::Slice

Sequence of Tokens Read more
Source§

type IterOffsets = <I as Stream>::IterOffsets

Iterate with the offset from the current location
Source§

type Checkpoint = Checkpoint<<I as Stream>::Checkpoint, Recoverable<I, E>>

A parse location within the stream
Source§

fn iter_offsets(&self) -> Self::IterOffsets

Iterate with the offset from the current location
Source§

fn eof_offset(&self) -> usize

Returns the offset to the end of the input
Source§

fn next_token(&mut self) -> Option<Self::Token>

Split off the next token from the input
Source§

fn peek_token(&self) -> Option<Self::Token>

Split off the next token from the input
Source§

fn offset_for<P>(&self, predicate: P) -> Option<usize>
where P: Fn(Self::Token) -> bool,

Finds the offset of the next matching token
Source§

fn offset_at(&self, tokens: usize) -> Result<usize, Needed>

Get the offset for the number of tokens into the stream Read more
Source§

fn next_slice(&mut self, offset: usize) -> Self::Slice

Split off a slice of tokens from the input Read more
Source§

unsafe fn next_slice_unchecked(&mut self, offset: usize) -> Self::Slice

Split off a slice of tokens from the input Read more
Source§

fn peek_slice(&self, offset: usize) -> Self::Slice

Split off a slice of tokens from the input
Source§

unsafe fn peek_slice_unchecked(&self, offset: usize) -> Self::Slice

Split off a slice of tokens from the input Read more
Source§

fn checkpoint(&self) -> Self::Checkpoint

Save the current parse location within the stream
Source§

fn reset(&mut self, checkpoint: &Self::Checkpoint)

Revert the stream to a prior Self::Checkpoint Read more
Source§

fn raw(&self) -> &dyn Debug

👎Deprecated since 0.7.10: Replaced with Stream::trace
Deprecated for callers as of 0.7.10, instead call Stream::trace
Source§

fn finish(&mut self) -> Self::Slice

Advance to the end of the stream
Source§

fn peek_finish(&self) -> Self::Slice
where Self: Clone,

Advance to the end of the stream
Source§

fn trace(&self, f: &mut Formatter<'_>) -> Result

Write out a single-line summary of the current parse location
Source§

impl<I, E> StreamIsPartial for Recoverable<I, E>

Source§

type PartialState = <I as StreamIsPartial>::PartialState

Whether the stream is currently partial or complete
Source§

fn complete(&mut self) -> Self::PartialState

Mark the stream is complete
Source§

fn restore_partial(&mut self, state: Self::PartialState)

Restore the stream back to its previous state
Source§

fn is_partial_supported() -> bool

Report whether the Stream is can ever be incomplete
Source§

fn is_partial(&self) -> bool

Report whether the Stream is currently incomplete
Source§

impl<I, E> UpdateSlice for Recoverable<I, E>
where I: Stream + UpdateSlice, E: Debug,

Source§

fn update_slice(self, inner: Self::Slice) -> Self

Convert an Output type to be used as Stream

Auto Trait Implementations§

§

impl<I, E> Freeze for Recoverable<I, E>
where I: Freeze,

§

impl<I, E> RefUnwindSafe for Recoverable<I, E>

§

impl<I, E> Send for Recoverable<I, E>
where I: Send, E: Send,

§

impl<I, E> Sync for Recoverable<I, E>
where I: Sync, E: Sync,

§

impl<I, E> Unpin for Recoverable<I, E>
where I: Unpin, E: Unpin,

§

impl<I, E> UnwindSafe for Recoverable<I, E>
where I: UnwindSafe, E: UnwindSafe,

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.