Struct multipart::server::save::BufReader [−][src]
pub struct BufReader<R, P = StdPolicy> { /* fields omitted */ }
Expand description
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.
Implementations
impl<R> BufReader<R, StdPolicy>
[src]
impl<R> BufReader<R, StdPolicy>
[src]pub fn new(inner: R) -> BufReader<R, StdPolicy>ⓘNotable traits for BufReader<R, P>
impl<R, P> Read for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
[src]
pub fn new(inner: R) -> BufReader<R, StdPolicy>ⓘNotable traits for BufReader<R, P>
impl<R, P> Read for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
[src]Create a new BufReader
wrapping inner
, utilizing a buffer of
default capacity and the default ReaderPolicy
.
pub fn with_capacity(cap: usize, inner: R) -> BufReader<R, StdPolicy>ⓘNotable traits for BufReader<R, P>
impl<R, P> Read for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
[src]
pub fn with_capacity(cap: usize, inner: R) -> BufReader<R, StdPolicy>ⓘNotable traits for BufReader<R, P>
impl<R, P> Read for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
[src]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.
pub fn with_buffer(buf: Buffer, inner: R) -> BufReader<R, StdPolicy>ⓘNotable traits for BufReader<R, P>
impl<R, P> Read for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
[src]
pub fn with_buffer(buf: Buffer, inner: R) -> BufReader<R, StdPolicy>ⓘNotable traits for BufReader<R, P>
impl<R, P> Read for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
[src]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]
impl<R, P> BufReader<R, P>
[src]pub fn set_policy<P_>(self, policy: P_) -> BufReader<R, P_>ⓘNotable traits for BufReader<R, P>
impl<R, P> Read for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
where
P_: ReaderPolicy,
[src]
pub fn set_policy<P_>(self, policy: P_) -> BufReader<R, P_>ⓘNotable traits for BufReader<R, P>
impl<R, P> Read for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
where
P_: ReaderPolicy,
[src]Apply a new ReaderPolicy
to this BufReader
, returning the transformed type.
pub fn policy_mut(&mut self) -> &mut P
[src]
pub fn policy_mut(&mut self) -> &mut P
[src]Mutate the current ReaderPolicy
in-place.
If you want to change the type, use .set_policy()
.
pub fn make_room(&mut self)
[src]
pub fn make_room(&mut self)
[src]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).
pub fn reserve(&mut self, additional: usize)
[src]
pub fn reserve(&mut self, additional: usize)
[src]Ensure room in the buffer for at least additional
bytes. May not be
quite exact due to implementation details of the buffer’s allocator.
pub fn buffer(&self) -> &[u8]
[src]
pub fn buffer(&self) -> &[u8]
[src]Get the section of the buffer containing valid data; may be empty.
Call .consume()
to remove bytes from the beginning of this section.
pub fn get_mut(&mut self) -> &mut R
[src]
pub fn get_mut(&mut self) -> &mut R
[src]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.
pub fn into_inner(self) -> R
[src]
pub fn into_inner(self) -> R
[src]Consume self
and return the inner reader only.
pub fn into_inner_with_buffer(self) -> (R, Buffer)
[src]
pub fn into_inner_with_buffer(self) -> (R, Buffer)
[src]Consume self
and return both the underlying reader and the buffer.
See also: BufReader::unbuffer()
impl<R, P> BufReader<R, P> where
R: Read,
[src]
impl<R, P> BufReader<R, P> where
R: Read,
[src]pub fn read_into_buf(&mut self) -> Result<usize, Error>
[src]
pub fn read_into_buf(&mut self) -> Result<usize, Error>
[src]Unconditionally perform a read into the buffer.
Does not invoke ReaderPolicy
methods.
If the read was successful, returns the number of bytes read.
Trait Implementations
impl<R, P> BufRead for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
[src]
impl<R, P> BufRead for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
[src]pub fn fill_buf(&mut self) -> Result<&[u8], Error>
[src]
pub fn fill_buf(&mut self) -> Result<&[u8], Error>
[src]Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
pub fn consume(&mut self, amt: usize)
[src]
pub fn consume(&mut self, amt: usize)
[src]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
fn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8, Global>
) -> Result<usize, Error>
1.0.0[src]
fn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8, Global>
) -> Result<usize, Error>
1.0.0[src]Read all bytes into buf
until the delimiter byte
or EOF is reached. Read more
fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]Read all bytes until a newline (the 0xA
byte) is reached, and append
them to the provided buffer. Read more
impl<R, P> Read for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
[src]
impl<R, P> Read for BufReader<R, P> where
R: Read,
P: ReaderPolicy,
[src]pub fn read(&mut self, out: &mut [u8]) -> Result<usize, Error>
[src]
pub fn read(&mut self, out: &mut [u8]) -> Result<usize, Error>
[src]Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
1.36.0[src]
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
1.36.0[src]Like read
, except that it reads into a slice of buffers. Read more
fn is_read_vectored(&self) -> bool
[src]
fn is_read_vectored(&self) -> bool
[src]can_vector
)Determines if this Read
er has an efficient read_vectored
implementation. Read more
unsafe fn initializer(&self) -> Initializer
[src]
unsafe fn initializer(&self) -> Initializer
[src]read_initializer
)Determines if this Read
er can work with buffers of uninitialized
memory. Read more
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
1.0.0[src]
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
1.0.0[src]Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]Read all bytes until EOF in this source, appending them to buf
. Read more
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]Read the exact number of bytes required to fill buf
. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]Creates a “by reference” adaptor for this instance of Read
. Read more
impl<R, P> Seek for BufReader<R, P> where
R: Seek,
P: ReaderPolicy,
[src]
impl<R, P> Seek for BufReader<R, P> where
R: Seek,
P: ReaderPolicy,
[src]pub fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
[src]
pub fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
[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)
.
fn rewind(&mut self) -> Result<(), Error>
[src]
fn rewind(&mut self) -> Result<(), Error>
[src]seek_rewind
)Rewind to the beginning of a stream. Read more
Auto Trait Implementations
impl<R, P> RefUnwindSafe for BufReader<R, P> where
P: RefUnwindSafe,
R: RefUnwindSafe,
P: RefUnwindSafe,
R: RefUnwindSafe,
impl<R, P> Send for BufReader<R, P> where
P: Send,
R: Send,
P: Send,
R: Send,
impl<R, P> Sync for BufReader<R, P> where
P: Sync,
R: Sync,
P: Sync,
R: Sync,
impl<R, P> Unpin for BufReader<R, P> where
P: Unpin,
R: Unpin,
P: Unpin,
R: Unpin,
impl<R, P> UnwindSafe for BufReader<R, P> where
P: UnwindSafe,
R: UnwindSafe,
P: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<R> ReadBytesExt for R where
R: Read + ?Sized,
impl<R> ReadBytesExt for R where
R: Read + ?Sized,
fn read_u8(&mut self) -> Result<u8, Error>
fn read_u8(&mut self) -> Result<u8, Error>
Reads an unsigned 8 bit integer from the underlying reader. Read more
fn read_i8(&mut self) -> Result<i8, Error>
fn read_i8(&mut self) -> Result<i8, Error>
Reads a signed 8 bit integer from the underlying reader. Read more
fn read_u16<T>(&mut self) -> Result<u16, Error> where
T: ByteOrder,
fn read_u16<T>(&mut self) -> Result<u16, Error> where
T: ByteOrder,
Reads an unsigned 16 bit integer from the underlying reader. Read more
fn read_i16<T>(&mut self) -> Result<i16, Error> where
T: ByteOrder,
fn read_i16<T>(&mut self) -> Result<i16, Error> where
T: ByteOrder,
Reads a signed 16 bit integer from the underlying reader. Read more
fn read_u24<T>(&mut self) -> Result<u32, Error> where
T: ByteOrder,
fn read_u24<T>(&mut self) -> Result<u32, Error> where
T: ByteOrder,
Reads an unsigned 24 bit integer from the underlying reader. Read more
fn read_i24<T>(&mut self) -> Result<i32, Error> where
T: ByteOrder,
fn read_i24<T>(&mut self) -> Result<i32, Error> where
T: ByteOrder,
Reads a signed 24 bit integer from the underlying reader. Read more
fn read_u32<T>(&mut self) -> Result<u32, Error> where
T: ByteOrder,
fn read_u32<T>(&mut self) -> Result<u32, Error> where
T: ByteOrder,
Reads an unsigned 32 bit integer from the underlying reader. Read more
fn read_i32<T>(&mut self) -> Result<i32, Error> where
T: ByteOrder,
fn read_i32<T>(&mut self) -> Result<i32, Error> where
T: ByteOrder,
Reads a signed 32 bit integer from the underlying reader. Read more
fn read_u48<T>(&mut self) -> Result<u64, Error> where
T: ByteOrder,
fn read_u48<T>(&mut self) -> Result<u64, Error> where
T: ByteOrder,
Reads an unsigned 48 bit integer from the underlying reader. Read more
fn read_i48<T>(&mut self) -> Result<i64, Error> where
T: ByteOrder,
fn read_i48<T>(&mut self) -> Result<i64, Error> where
T: ByteOrder,
Reads a signed 48 bit integer from the underlying reader. Read more
fn read_u64<T>(&mut self) -> Result<u64, Error> where
T: ByteOrder,
fn read_u64<T>(&mut self) -> Result<u64, Error> where
T: ByteOrder,
Reads an unsigned 64 bit integer from the underlying reader. Read more
fn read_i64<T>(&mut self) -> Result<i64, Error> where
T: ByteOrder,
fn read_i64<T>(&mut self) -> Result<i64, Error> where
T: ByteOrder,
Reads a signed 64 bit integer from the underlying reader. Read more
fn read_u128<T>(&mut self) -> Result<u128, Error> where
T: ByteOrder,
fn read_u128<T>(&mut self) -> Result<u128, Error> where
T: ByteOrder,
Reads an unsigned 128 bit integer from the underlying reader. Read more
fn read_i128<T>(&mut self) -> Result<i128, Error> where
T: ByteOrder,
fn read_i128<T>(&mut self) -> Result<i128, Error> where
T: ByteOrder,
Reads a signed 128 bit integer from the underlying reader. Read more
fn read_uint<T>(&mut self, nbytes: usize) -> Result<u64, Error> where
T: ByteOrder,
fn read_uint<T>(&mut self, nbytes: usize) -> Result<u64, Error> where
T: ByteOrder,
Reads an unsigned n-bytes integer from the underlying reader. Read more
fn read_int<T>(&mut self, nbytes: usize) -> Result<i64, Error> where
T: ByteOrder,
fn read_int<T>(&mut self, nbytes: usize) -> Result<i64, Error> where
T: ByteOrder,
Reads a signed n-bytes integer from the underlying reader. Read more
fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error> where
T: ByteOrder,
fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error> where
T: ByteOrder,
Reads an unsigned n-bytes integer from the underlying reader.
fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error> where
T: ByteOrder,
fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error> where
T: ByteOrder,
Reads a signed n-bytes integer from the underlying reader.
fn read_f32<T>(&mut self) -> Result<f32, Error> where
T: ByteOrder,
fn read_f32<T>(&mut self) -> Result<f32, Error> where
T: ByteOrder,
Reads a IEEE754 single-precision (4 bytes) floating point number from the underlying reader. Read more
fn read_f64<T>(&mut self) -> Result<f64, Error> where
T: ByteOrder,
fn read_f64<T>(&mut self) -> Result<f64, Error> where
T: ByteOrder,
Reads a IEEE754 double-precision (8 bytes) floating point number from the underlying reader. Read more
fn read_u16_into<T>(&mut self, dst: &mut [u16]) -> Result<(), Error> where
T: ByteOrder,
fn read_u16_into<T>(&mut self, dst: &mut [u16]) -> Result<(), Error> where
T: ByteOrder,
Reads a sequence of unsigned 16 bit integers from the underlying reader. Read more
fn read_u32_into<T>(&mut self, dst: &mut [u32]) -> Result<(), Error> where
T: ByteOrder,
fn read_u32_into<T>(&mut self, dst: &mut [u32]) -> Result<(), Error> where
T: ByteOrder,
Reads a sequence of unsigned 32 bit integers from the underlying reader. Read more
fn read_u64_into<T>(&mut self, dst: &mut [u64]) -> Result<(), Error> where
T: ByteOrder,
fn read_u64_into<T>(&mut self, dst: &mut [u64]) -> Result<(), Error> where
T: ByteOrder,
Reads a sequence of unsigned 64 bit integers from the underlying reader. Read more
fn read_u128_into<T>(&mut self, dst: &mut [u128]) -> Result<(), Error> where
T: ByteOrder,
fn read_u128_into<T>(&mut self, dst: &mut [u128]) -> Result<(), Error> where
T: ByteOrder,
Reads a sequence of unsigned 128 bit integers from the underlying reader. Read more
fn read_i8_into(&mut self, dst: &mut [i8]) -> Result<(), Error>
fn read_i8_into(&mut self, dst: &mut [i8]) -> Result<(), Error>
Reads a sequence of signed 8 bit integers from the underlying reader. Read more
fn read_i16_into<T>(&mut self, dst: &mut [i16]) -> Result<(), Error> where
T: ByteOrder,
fn read_i16_into<T>(&mut self, dst: &mut [i16]) -> Result<(), Error> where
T: ByteOrder,
Reads a sequence of signed 16 bit integers from the underlying reader. Read more
fn read_i32_into<T>(&mut self, dst: &mut [i32]) -> Result<(), Error> where
T: ByteOrder,
fn read_i32_into<T>(&mut self, dst: &mut [i32]) -> Result<(), Error> where
T: ByteOrder,
Reads a sequence of signed 32 bit integers from the underlying reader. Read more
fn read_i64_into<T>(&mut self, dst: &mut [i64]) -> Result<(), Error> where
T: ByteOrder,
fn read_i64_into<T>(&mut self, dst: &mut [i64]) -> Result<(), Error> where
T: ByteOrder,
Reads a sequence of signed 64 bit integers from the underlying reader. Read more
fn read_i128_into<T>(&mut self, dst: &mut [i128]) -> Result<(), Error> where
T: ByteOrder,
fn read_i128_into<T>(&mut self, dst: &mut [i128]) -> Result<(), Error> where
T: ByteOrder,
Reads a sequence of signed 128 bit integers from the underlying reader. Read more
fn read_f32_into<T>(&mut self, dst: &mut [f32]) -> Result<(), Error> where
T: ByteOrder,
fn read_f32_into<T>(&mut self, dst: &mut [f32]) -> Result<(), Error> where
T: ByteOrder,
Reads a sequence of IEEE754 single-precision (4 bytes) floating point numbers from the underlying reader. Read more
fn read_f32_into_unchecked<T>(&mut self, dst: &mut [f32]) -> Result<(), Error> where
T: ByteOrder,
fn read_f32_into_unchecked<T>(&mut self, dst: &mut [f32]) -> Result<(), Error> where
T: ByteOrder,
please use read_f32_into
instead
DEPRECATED. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> DebugAny for T where
T: Any + Debug,
T: Any + Debug,
impl<T> UnsafeAny for T where
T: Any,
T: Any,