Struct source_span::SourceBuffer [−][src]
pub struct SourceBuffer<E, I: Iterator<Item = Result<char, E>>, M: Metrics> { /* fields omitted */ }
Expand description
Lazy string buffer that fills up on demand, can be iterated and indexed by character position.
The SourceBuffer
wraps aroung a char
iterator. It can be itself used as
a char
iterator, or as a SourceBuffer
to access an arbitrary fragment of
the input source stream.
Implementations
Create a new empty buffer starting at the given position.
Get the index of the char at the given cursor position if it is in the buffer. If it is not in the buffer but after the buffered content, the input stream will be read until the buffer span includes the given position.
Returns None
if the given position if previous to the buffer start
positions, if the source stream ends before the given position, or
if the line at the given position is shorter than the given position
column.
Get the char at the given position if it is in the buffer. If it is not in the buffer yet, the input stream will be pulled until the buffer span includes the given position.
Returns None
if the given position is out of range, if the source
stream ends before the given position, or if the line at the given
position is shorter than the given position column.
Get the character at the given index.
If it is not in the buffer but after the buffered content, the input
stream will be read until the buffer span includes the given
position. Returns None
if the source stream ends before the given
position.
Returns an iterator through the characters of the buffer from the begining of it.
When it reaches the end of the buffer, the buffer will start reading from the source stream.
Returns an iterator through the characters of the buffer from the given position.
If the input position precedes the buffer start position, then it will start from the buffer start position. When it reaches the end of the buffer, the buffer will start reading from the source stream.
Returns an iterator through the characters of the buffer in the given span.
If the input start position precedes the buffer start position, then it will start from the buffer start position. When it reaches the end of the buffer, the buffer will start reading from the source stream.