Struct buf_redux::BufReader [] [src]

pub struct BufReader<R, Rs = DefaultReadStrategy, Ms = DefaultMoveStrategy> { /* fields omitted */ }

A drop-in replacement for std::io::BufReader with more functionality.

Original method names/signatures and implemented traits are left untouched, making replacement as simple as swapping the import of the type.

Methods

impl<R> BufReader<R, DefaultReadStrategy, DefaultMoveStrategy>
[src]

Create a new BufReader wrapping inner, with a buffer of a default capacity and the default strategies.

Create a new BufReader wrapping inner with a capacity of at least cap bytes and the default strategies.

The actual capacity of the buffer may vary based on implementation details of the buffer's allocator.

impl<R, Rs: ReadStrategy, Ms: MoveStrategy> BufReader<R, Rs, Ms>
[src]

Create a new BufReader wrapping inner, with a default buffer capacity and with the given ReadStrategy and MoveStrategy.

Create a new BufReader wrapping inner, with a buffer capacity of at least cap bytes and the given ReadStrategy and MoveStrategy.

The actual capacity of the buffer may vary based on implementation details of the buffer's allocator.

Apply a new MoveStrategy to this BufReader, returning the transformed type.

Apply a new ReadStrategy to this BufReader, returning the transformed type.

Accessor for updating the MoveStrategy in-place.

If you want to change the type, use .move_strategy().

Accessor for updating the ReadStrategy in-place.

If you want to change the type, use .read_strategy().

Move data to the start of the buffer, making room at the end for more reading.

Grow the internal buffer by at least additional bytes. May not be quite exact due to implementation details of the buffer's allocator.

Note

This should not be called frequently as each call will incur a reallocation.

Get the section of the buffer containing valid data; may be empty.

Call .consume() to remove bytes from the beginning of this section.

Get the current number of bytes available in the buffer.

Get the total buffer capacity.

Get an immutable reference to the underlying reader.

Get a mutable reference to the underlying reader.

Note

Reading directly from the underlying reader is not recommended, as some data has likely already been moved into the buffer.

Consume self and return the inner reader only.

Consume self and return both the underlying reader and the buffer, with the data moved to the beginning and the length truncated to contain only valid data.

See also: BufReader::unbuffer()

Consume self and return an adapter which implements Read and will empty the buffer before reading directly from the underlying reader.

impl<R: Read, Rs: ReadStrategy, Ms: MoveStrategy> BufReader<R, Rs, Ms>
[src]

Unconditionally perform a read into the buffer, calling .make_room() if appropriate or necessary, as determined by the implementation.

If the read was successful, returns the number of bytes read.

impl<R: Read, Rs, Ms> BufReader<R, Rs, Ms>
[src]

Box the inner reader without losing data.

Trait Implementations

impl<R: Read, Rs: ReadStrategy, Ms: MoveStrategy> Read for BufReader<R, Rs, Ms>
[src]

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

Read all bytes until EOF in this source, placing them into buf. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read the exact number of bytes required to fill buf. Read more

Creates a "by reference" adaptor for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

🔬 This is a nightly-only experimental API. (io)

the semantics of a partial read/write of where errors happen is currently unclear and may change

Transforms this Read instance to an Iterator over chars. Read more

Creates an adaptor which will chain this stream with another. Read more

Creates an adaptor which will read at most limit bytes from it. Read more

impl<R: Read, Rs: ReadStrategy, Ms: MoveStrategy> BufRead for BufReader<R, Rs, Ms>
[src]

Fills the internal buffer of this object, returning the buffer contents. Read more

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

Read all bytes into buf until the delimiter byte or EOF is reached. Read more

Read all bytes until a newline (the 0xA byte) is reached, and append them to the provided buffer. Read more

Returns an iterator over the contents of this reader split on the byte byte. Read more

Returns an iterator over the lines of this reader. Read more

impl<R: Debug, Rs: ReadStrategy, Ms: MoveStrategy> Debug for BufReader<R, Rs, Ms>
[src]

Formats the value using the given formatter.

impl<R: Seek, Rs: ReadStrategy, Ms: MoveStrategy> Seek for BufReader<R, Rs, Ms>
[src]

Seek to an offset, in bytes, in the underlying reader.

The position used for seeking with SeekFrom::Current(_) is the position the underlying reader would be at if the BufReader had no internal buffer.

Seeking always discards the internal buffer, even if the seek position would otherwise fall within it. This guarantees that calling .unwrap() immediately after a seek yields the underlying reader at the same position.

See std::io::Seek for more details.

Note: In the edge case where you're seeking with SeekFrom::Current(n) where n minus the internal buffer length underflows an i64, two seeks will be performed instead of one. If the second seek returns Err, the underlying reader will be left at the same position it would have if you seeked to SeekFrom::Current(0).