[][src]Struct multipart::server::save::BufReader

pub struct BufReader<R, P = StdPolicy> { /* 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.

By default this type implements the behavior of its std counterpart: it only reads into the buffer when it is empty.

To change this type's behavior, change the policy with .set_policy() using a type from the policy module or your own implementation of ReaderPolicy.

Policies that perform alternating reads and consumes without completely emptying the buffer may benefit from using a ringbuffer via the new_ringbuf() and with_capacity_ringbuf() constructors. Ringbuffers are only available on supported platforms with the slice-deque feature and have some other caveats; see the crate root docs for more details.

Methods

impl<R> BufReader<R, StdPolicy>
[src]

Important traits for BufReader<R, P>

Create a new BufReader wrapping inner, utilizing a buffer of default capacity and the default ReaderPolicy.

Important traits for BufReader<R, P>

Create a new BufReader wrapping inner, utilizing a buffer with a capacity of at least cap bytes and the default ReaderPolicy.

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

Important traits for BufReader<R, P>

Wrap inner with an existing Buffer instance and the default ReaderPolicy.

Note

Does not clear the buffer first! If there is data already in the buffer then it will be returned in read() and fill_buf() ahead of any data from inner.

impl<R, P> BufReader<R, P>
[src]

Important traits for BufReader<R, P>

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

Mutate the current ReaderPolicy in-place.

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

Inspect the current ReaderPolicy.

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

This is a no-op with the *_ringbuf() constructors (requires slice-deque feature).

Ensure room in the buffer for at least additional bytes. May not be quite exact due to implementation details of the buffer's allocator.

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.

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, P> BufReader<R, P> where
    R: Read
[src]

Unconditionally perform a read into the buffer.

Does not invoke ReaderPolicy methods.

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

Important traits for BufReader<R, P>

Box the inner reader without losing data.

Trait Implementations

impl<R, P> Seek for BufReader<R, P> where
    P: ReaderPolicy,
    R: Seek
[src]

Seek to an ofPet, 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).

impl<R, P> BufRead for BufReader<R, P> where
    P: ReaderPolicy,
    R: Read
[src]

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, P> Read for BufReader<R, P> where
    P: ReaderPolicy,
    R: Read
[src]

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

Determines if this Reader can work with buffers of uninitialized memory. Read more

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

Read all bytes until EOF in this source, appending them to 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

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, P> Debug for BufReader<R, P> where
    P: Debug,
    R: Debug
[src]

Auto Trait Implementations

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

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

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

Get the TypeId of this object.

impl<R> ReadBytesExt for R where
    R: Read + ?Sized

Reads an unsigned 8 bit integer from the underlying reader. Read more

Reads a signed 8 bit integer from the underlying reader. Read more

Reads an unsigned 16 bit integer from the underlying reader. Read more

Reads a signed 16 bit integer from the underlying reader. Read more

Reads an unsigned 24 bit integer from the underlying reader. Read more

Reads a signed 24 bit integer from the underlying reader. Read more

Reads an unsigned 32 bit integer from the underlying reader. Read more

Reads a signed 32 bit integer from the underlying reader. Read more

Reads an unsigned 48 bit integer from the underlying reader. Read more

Reads a signed 48 bit integer from the underlying reader. Read more

Reads an unsigned 64 bit integer from the underlying reader. Read more

Reads a signed 64 bit integer from the underlying reader. Read more

Reads an unsigned n-bytes integer from the underlying reader. Read more

Reads a signed n-bytes integer from the underlying reader. Read more

Reads a IEEE754 single-precision (4 bytes) floating point number from the underlying reader. Read more

Reads a IEEE754 double-precision (8 bytes) floating point number from the underlying reader. Read more

Reads a sequence of unsigned 16 bit integers from the underlying reader. Read more

Reads a sequence of unsigned 32 bit integers from the underlying reader. Read more

Reads a sequence of unsigned 64 bit integers from the underlying reader. Read more

Reads a sequence of signed 16 bit integers from the underlying reader. Read more

Reads a sequence of signed 32 bit integers from the underlying reader. Read more

Reads a sequence of signed 64 bit integers from the underlying reader. Read more

Reads a sequence of IEEE754 single-precision (4 bytes) floating point numbers from the underlying reader. Read more

Deprecated since 1.2.0

: please use read_f32_into instead

DEPRECATED. Read more

Reads a sequence of IEEE754 double-precision (8 bytes) floating point numbers from the underlying reader. Read more

Deprecated since 1.2.0

: please use read_f64_into instead

DEPRECATED. Read more

impl<T> DebugAny for T where
    T: Any + Debug

impl<T> UnsafeAny for T where
    T: Any