Struct InputStream

Source
pub struct InputStream<Data: Deref> { /* private fields */ }
Expand description

Default rust target input stream.

Since Rust uses UTF-8 format which does not support indexing by char, InputStream<&str> has slightly different index behavior in compare to java runtime when there are non-ASCII unicode characters. If you need it to generate exactly the same indexes as Java runtime, you have to use CodePoint8/16/32BitCharStream, which does not use rusts native str type, so it would do additional conversions and allocations along the way.

Implementations§

Source§

impl<Data: ?Sized + InputData> InputStream<Box<Data>>

Source

pub fn new_owned(data: Box<Data>) -> Self

Creates new InputStream over owned data

Source§

impl<'a, Data> InputStream<&'a Data>
where Data: ?Sized + InputData,

Source

pub fn new(data_raw: &'a Data) -> Self

Creates new InputStream over borrowed data

Source§

impl<'a, Data: Deref> InputStream<Data>
where Data::Target: InputData,

Source

pub fn reset(&mut self)

Resets input stream to start from the beginning of this slice

Trait Implementations§

Source§

impl<'a, T> CharStream<&'a [T]> for InputStream<&'a [T]>
where [T]: InputData,

Source§

fn get_text(&self, a: isize, b: isize) -> &'a [T]

Returns underlying data piece, either slice or owned copy. Panics if provided indexes are invalid Called by parser only on token intervals. This fact can be used by custom implementations
Source§

impl<'a, T> CharStream<Cow<'a, [T]>> for InputStream<&'a [T]>
where [T]: InputData,

Source§

fn get_text(&self, a: isize, b: isize) -> Cow<'a, [T]>

Returns underlying data piece, either slice or owned copy. Panics if provided indexes are invalid Called by parser only on token intervals. This fact can be used by custom implementations
Source§

impl<'a, 'b, T> CharStream<Cow<'b, str>> for InputStream<&'a [T]>
where [T]: InputData,

Source§

fn get_text(&self, a: isize, b: isize) -> Cow<'b, str>

Returns underlying data piece, either slice or owned copy. Panics if provided indexes are invalid Called by parser only on token intervals. This fact can be used by custom implementations
Source§

impl<'a, T> CharStream<String> for InputStream<&'a [T]>
where [T]: InputData,

Source§

fn get_text(&self, a: isize, b: isize) -> String

Returns underlying data piece, either slice or owned copy. Panics if provided indexes are invalid Called by parser only on token intervals. This fact can be used by custom implementations
Source§

impl<'a, T: From<&'a str>> CharStream<T> for InputStream<&'a str>

Source§

fn get_text(&self, start: isize, stop: isize) -> T

Returns underlying data piece, either slice or owned copy. Panics if provided indexes are invalid Called by parser only on token intervals. This fact can be used by custom implementations
Source§

impl<T: From<D::Owned>, D: ?Sized + InputData> CharStream<T> for InputStream<Box<D>>

Source§

fn get_text(&self, start: isize, stop: isize) -> T

Returns underlying data piece, either slice or owned copy. Panics if provided indexes are invalid Called by parser only on token intervals. This fact can be used by custom implementations
Source§

impl<Data: Debug + Deref> Debug for InputStream<Data>

Source§

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

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

impl<'a, Data: Deref> IntStream for InputStream<Data>
where Data::Target: InputData,

Source§

fn consume(&mut self)

Consumes the current symbol in the stream. Advances this stream to the next element. Read more
Source§

fn la(&mut self, offset: isize) -> isize

Lookaheads (or loopbacks if i is negative) Read more
Source§

fn mark(&mut self) -> isize

After this call subsequent calls to seek must succeed if seek index is greater than mark index Read more
Source§

fn release(&mut self, _marker: isize)

Releases marker
Source§

fn index(&self) -> isize

Returns current position of the input stream Read more
Source§

fn seek(&mut self, index: isize)

Put stream back in state it was when it was in index position Read more
Source§

fn size(&self) -> isize

Returns the total number of symbols in the stream.
Source§

fn get_source_name(&self) -> String

Returns name of the source this stream operates over if any
Source§

impl<'a, T> TidAble<'a> for InputStream<&'a T>
where T: ?Sized + 'static,

Source§

impl<'a, T> TidAble<'a> for InputStream<Box<T>>
where T: ?Sized + 'static,

Auto Trait Implementations§

§

impl<Data> Freeze for InputStream<Data>
where Data: Freeze,

§

impl<Data> RefUnwindSafe for InputStream<Data>
where Data: RefUnwindSafe,

§

impl<Data> Send for InputStream<Data>
where Data: Send,

§

impl<Data> Sync for InputStream<Data>
where Data: Sync,

§

impl<Data> Unpin for InputStream<Data>
where Data: Unpin,

§

impl<Data> UnwindSafe for InputStream<Data>
where Data: 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> AnyExt for T
where T: Any + ?Sized,

Source§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
Source§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
Source§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
Source§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
Source§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
Source§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
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, X> CoerceTo<T> for X
where T: CoerceFrom<X> + ?Sized,

Source§

fn coerce_rc_to(self: Rc<X>) -> Rc<T>

Source§

fn coerce_box_to(self: Box<X>) -> Box<T>

Source§

fn coerce_ref_to(&self) -> &T

Source§

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

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<'a, T> Tid<'a> for T
where T: TidAble<'a> + ?Sized,

Source§

fn self_id(&self) -> TypeId

Returns type id of the type of self Read more
Source§

fn id() -> TypeId

Returns type id of this type
Source§

impl<'a, X> TidExt<'a> for X
where X: Tid<'a> + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: Tid<'a>,

Returns true if type behind self is equal to the type of T.
Source§

fn downcast_ref<'b, T>(&'b self) -> Option<&'b T>
where T: Tid<'a>,

Attempts to downcast self to T behind reference
Source§

fn downcast_mut<'b, T>(&'b mut self) -> Option<&'b mut T>
where T: Tid<'a>,

Attempts to downcast self to T behind mutable reference
Source§

fn downcast_rc<T>(self: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Tid<'a>,

Attempts to downcast self to T behind Rc pointer
Source§

fn downcast_arc<T>(self: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Tid<'a>,

Attempts to downcast self to T behind Arc pointer
Source§

fn downcast_box<T>(self: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Tid<'a>,

Attempts to downcast self to T behind Box pointer
Source§

fn downcast_move<T>(self) -> Option<T>
where T: Tid<'a>, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
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.