Skip to main content

BufferedReader

Struct BufferedReader 

Source
pub struct BufferedReader { /* private fields */ }
Expand description

A simple in-memory buffered reader over a byte slice.

Simulates buffered line reading for I/O processing within the elaborator.

Implementations§

Source§

impl BufferedReader

Source

pub fn new(data: Vec<u8>) -> Self

Create a new buffered reader with default capacity (8 KiB).

Source

pub fn from_str(s: &str) -> Self

Create a buffered reader from a string.

Source

pub fn read_byte(&mut self) -> Option<u8>

Read a single byte, or None if at end.

Source

pub fn read_line(&mut self) -> Option<String>

Read the next line (up to and including \n).

Returns None when the buffer is exhausted.

Source

pub fn read_to_string(&mut self) -> Result<String, IoError>

Read all remaining content as a string.

Source

pub fn read_exact(&mut self, n: usize) -> Result<Vec<u8>, IoError>

Read exactly n bytes.

Returns an error if fewer than n bytes remain.

Source

pub fn peek(&self) -> Option<u8>

Peek at the next byte without consuming it.

Source

pub fn is_eof(&self) -> bool

Check if the reader is at end of data.

Source

pub fn remaining(&self) -> usize

Return the number of bytes remaining.

Source

pub fn reset(&mut self)

Reset the reader to the beginning.

Source

pub fn skip(&mut self, n: usize)

Skip n bytes.

Source

pub fn capacity(&self) -> usize

Return the buffer capacity.

Source

pub fn lines(&mut self) -> Vec<String>

Collect all lines into a vector.

Auto Trait Implementations§

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, 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.