Struct axstd::io::BufReader

source ·
pub struct BufReader<R> { /* private fields */ }
Expand description

The BufReader<R> struct adds buffering to any reader.

Implementations§

source§

impl<R> BufReader<R>
where R: Read,

source

pub const fn new(inner: R) -> BufReader<R>

Creates a new BufReader<R> with a default buffer capacity (1 KB).

source§

impl<R> BufReader<R>

source

pub const fn get_ref(&self) -> &R

Gets a reference to the underlying reader.

source

pub fn get_mut(&mut self) -> &mut R

Gets a mutable reference to the underlying reader.

source

pub fn buffer(&self) -> &[u8]

Returns a reference to the internally buffered data.

Unlike fill_buf, this will not attempt to fill the buffer if it is empty.

source

pub const fn capacity(&self) -> usize

Returns the number of bytes the internal buffer can hold at once.

source

pub fn into_inner(self) -> R

Unwraps this BufReader<R>, returning the underlying reader.

Trait Implementations§

source§

impl<R> BufRead for BufReader<R>
where R: Read,

source§

fn fill_buf(&mut self) -> Result<&[u8], AxError>

Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty.
source§

fn consume(&mut self, amt: usize)

Tells this buffer that amt bytes have been consumed from the buffer, so they should no longer be returned in calls to read.
source§

fn has_data_left(&mut self) -> Result<bool, AxError>

Check if the underlying Read has any data left to be read.
source§

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, AxError>

Available on crate feature alloc only.
Read all bytes into buf until the delimiter byte or EOF is reached.
source§

fn read_line(&mut self, buf: &mut String) -> Result<usize, AxError>

Available on crate feature alloc only.
Read all bytes until a newline (the 0xA byte) is reached, and append them to the provided String buffer.
source§

impl<R> Read for BufReader<R>
where R: Read,

source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, AxError>

Pull some bytes from this source into the specified buffer, returning how many bytes were read.
source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), AxError>

Read the exact number of bytes required to fill buf.
source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, AxError>

Available on crate feature alloc only.
Read all bytes until EOF in this source, placing them into buf.
source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, AxError>

Available on crate feature alloc only.
Read all bytes until EOF in this source, appending them to buf.
source§

fn read_full(&mut self, buf: &mut [u8]) -> Result<usize, AxError>

Read the exact number of bytes required to fill buf.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<R> UnwindSafe for BufReader<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> AsAny for T
where T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

把当前对象转化为 Any 类型,供后续 downcast 使用
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

供 downcast_mut 使用
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>,

§

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

§

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.