Skip to main content

IoInput

Struct IoInput 

Source
pub struct IoInput<R> { /* private fields */ }
Available on crate feature std only.
Expand description

Input type which supports seekable readers. Uses a BufReader internally to buffer input and avoid unnecessary IO calls.

Only available with the std feature

Implementations§

Source§

impl<R: Read + Seek> IoInput<R>

Source

pub fn new(reader: R) -> IoInput<R>

Create a new IoReader from a seekable reader.

Trait Implementations§

Source§

impl<'src, R: Read + Seek + 'src> Input<'src> for IoInput<R>

Source§

type Cursor = usize

The type used to keep track of the current location in the stream. Read more
Source§

type Span = SimpleSpan

The type of a span on this input. Read more
Source§

type Token = u8

The type of singular tokens generated by the input. Read more
Source§

type MaybeToken = u8

The token type returned by Input::next_maybe, allowing abstracting over by-value and by-reference inputs. Read more
Source§

type Cache = IoInput<R>

A type that contains cached or constant data pertaining to an input. Read more
Source§

fn begin(self) -> (Self::Cursor, Self::Cache)

Create an initial cursor and cache at the start of the input.
Source§

fn cursor_location(cursor: &Self::Cursor) -> usize

Return the ‘location’ associated with the given cursor. Read more
Source§

unsafe fn next_maybe( this: &mut Self::Cache, cursor: &mut Self::Cursor, ) -> Option<Self::MaybeToken>

Pull the next token, if any, from the input. Read more
Source§

unsafe fn span( _this: &mut Self::Cache, range: Range<&Self::Cursor>, ) -> Self::Span

Create a span going from the start cursor to the end cursor (exclusive). Read more
Source§

fn with_context<S: Span>(self, context: S::Context) -> WithContext<S, Self>
where Self: Sized,

Add extra context within spans generated by this input. Read more
Source§

fn map<T, S, F>(self, eoi: S, f: F) -> MappedInput<'src, T, S, Self, F>
where Self: Sized, F: Fn(Self::MaybeToken) -> (<Self::MaybeToken as IntoMaybe<'src, Self::Token>>::Proj<T>, <Self::MaybeToken as IntoMaybe<'src, Self::Token>>::Proj<S>) + 'src, T: 'src, S: Span + 'src,

Map tokens of the input into separate token and span types, using the provided function. Read more
Source§

fn split_token_span<T, S>(self, eoi: S) -> MappedInput<'src, T, S, Self>
where Self: Input<'src, Token = (T, S), MaybeToken = &'src (T, S)> + Sized, T: 'src, S: Span + 'src,

Take an input (such as a slice) with token type (T, S) and turns it into one that produces tokens of type T and spans of type S. Read more
Source§

fn split_spanned<T, S>(self, eoi: S) -> MappedInput<'src, T, S, Self>
where Self: Input<'src, Token = S::Spanned, MaybeToken = &'src S::Spanned> + Sized, T: 'src, S: WrappingSpan<T> + 'src,

Take an input (such as a slice) with token type T where T is a spanned type, and split it into its inner value and token. Read more
Source§

fn map_span<S: Span, F>(self, map_fn: F) -> MappedSpan<S, Self, F>
where Self: Input<'src> + Sized, F: Fn(Self::Span) -> S,

Map the spans output for this input to a different output span. Read more
Source§

impl<'src, R: Read + Seek + 'src> ValueInput<'src> for IoInput<R>

Source§

unsafe fn next( this: &mut Self::Cache, cursor: &mut Self::Cursor, ) -> Option<Self::Token>

Get the next cursor from the provided one, and the next token if it exists Read more

Auto Trait Implementations§

§

impl<R> Freeze for IoInput<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for IoInput<R>
where R: RefUnwindSafe,

§

impl<R> Send for IoInput<R>
where R: Send,

§

impl<R> Sync for IoInput<R>
where R: Sync,

§

impl<R> Unpin for IoInput<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for IoInput<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for IoInput<R>
where R: 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> 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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T, S> SpanWrap<S> for T
where S: WrappingSpan<T>,

Source§

fn with_span(self, span: S) -> S::Spanned

Invokes WrappingSpan::make_wrapped to wrap an AST node in a span.
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.