Struct multipart::server::save::BufReader
[−]
[src]
pub struct BufReader<R, Rs = IfEmpty, Ms = AtEndLessThan1k> { /* 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, IfEmpty, AtEndLessThan1k>
[src]
fn new(inner: R) -> BufReader<R, IfEmpty, AtEndLessThan1k>
[src]
Create a new BufReader
wrapping inner
, with a buffer of a
default capacity and the default strategies.
fn with_capacity(cap: usize, inner: R) -> BufReader<R, IfEmpty, AtEndLessThan1k>
[src]
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, Ms> BufReader<R, Rs, Ms> where
Ms: MoveStrategy,
Rs: ReadStrategy,
[src]
Ms: MoveStrategy,
Rs: ReadStrategy,
fn with_strategies(inner: R, rs: Rs, ms: Ms) -> BufReader<R, Rs, Ms>
[src]
Create a new BufReader
wrapping inner
, with a default buffer capacity
and with the given ReadStrategy
and MoveStrategy
.
fn with_cap_and_strategies(
inner: R,
cap: usize,
rs: Rs,
ms: Ms
) -> BufReader<R, Rs, Ms>
[src]
inner: R,
cap: usize,
rs: Rs,
ms: Ms
) -> BufReader<R, Rs, Ms>
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.
fn move_strategy<Ms_>(self, ms: Ms_) -> BufReader<R, Rs, Ms_> where
Ms_: MoveStrategy,
[src]
Ms_: MoveStrategy,
Apply a new MoveStrategy
to this BufReader
, returning the transformed type.
fn read_strategy<Rs_>(self, rs: Rs_) -> BufReader<R, Rs_, Ms> where
Rs_: ReadStrategy,
[src]
Rs_: ReadStrategy,
Apply a new ReadStrategy
to this BufReader
, returning the transformed type.
fn move_strategy_mut(&mut self) -> &mut Ms
[src]
Accessor for updating the MoveStrategy
in-place.
If you want to change the type, use .move_strategy()
.
fn read_strategy_mut(&mut self) -> &mut Rs
[src]
Accessor for updating the ReadStrategy
in-place.
If you want to change the type, use .read_strategy()
.
fn make_room(&mut self)
[src]
Move data to the start of the buffer, making room at the end for more reading.
fn grow(&mut self, additional: usize)
[src]
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.
fn get_buf(&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.
fn available(&self) -> usize
[src]
Get the current number of bytes available in the buffer.
fn capacity(&self) -> usize
[src]
Get the total buffer capacity.
fn get_ref(&self) -> &R
[src]
Get an immutable reference to the underlying reader.
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.
fn into_inner(self) -> R
[src]
Consume self
and return the inner reader only.
fn into_inner_with_buf(self) -> (R, Vec<u8>)
[src]
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()
fn unbuffer(self) -> Unbuffer<R>
[src]
Consume self
and return an adapter which implements Read
and will
empty the buffer before reading directly from the underlying reader.
impl<R, Rs, Ms> BufReader<R, Rs, Ms> where
Ms: MoveStrategy,
R: Read,
Rs: ReadStrategy,
[src]
Ms: MoveStrategy,
R: Read,
Rs: ReadStrategy,
fn read_into_buf(&mut self) -> Result<usize, Error>
[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, Rs, Ms> BufReader<R, Rs, Ms> where
R: Read,
[src]
R: Read,
fn boxed<'a>(self) -> BufReader<Box<Read + 'a>, Rs, Ms> where
R: 'a,
[src]
R: 'a,
Box the inner reader without losing data.
Trait Implementations
impl<R, Rs, Ms> Seek for BufReader<R, Rs, Ms> where
Ms: MoveStrategy,
R: Seek,
Rs: ReadStrategy,
[src]
Ms: MoveStrategy,
R: Seek,
Rs: ReadStrategy,
fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
[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)
.
impl<R, Rs, Ms> Debug for BufReader<R, Rs, Ms> where
Ms: MoveStrategy,
R: Debug,
Rs: ReadStrategy,
[src]
Ms: MoveStrategy,
R: Debug,
Rs: ReadStrategy,
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
impl<R, Rs, Ms> BufRead for BufReader<R, Rs, Ms> where
Ms: MoveStrategy,
R: Read,
Rs: ReadStrategy,
[src]
Ms: MoveStrategy,
R: Read,
Rs: ReadStrategy,
fn fill_buf(&mut self) -> Result<&[u8], Error>
[src]
Fills the internal buffer of this object, returning the buffer contents. Read more
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>) -> 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]
Read all bytes until a newline (the 0xA byte) is reached, and append them to the provided buffer. Read more
fn split(self, byte: u8) -> Split<Self>
1.0.0[src]
Returns an iterator over the contents of this reader split on the byte byte
. Read more
fn lines(self) -> Lines<Self>
1.0.0[src]
Returns an iterator over the lines of this reader. Read more
impl<R, Rs, Ms> Read for BufReader<R, Rs, Ms> where
Ms: MoveStrategy,
R: Read,
Rs: ReadStrategy,
[src]
Ms: MoveStrategy,
R: Read,
Rs: ReadStrategy,
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
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>) -> 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]
Read all bytes until EOF in this source, placing them into buf
. Read more
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]
Creates a "by reference" adaptor for this instance of Read
. Read more
fn bytes(self) -> Bytes<Self>
1.0.0[src]
Transforms this Read
instance to an [Iterator
] over its bytes. Read more
fn chars(self) -> Chars<Self>
[src]
🔬 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 [char
]s. Read more
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
Creates an adaptor which will chain this stream with another. Read more
fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
Creates an adaptor which will read at most limit
bytes from it. Read more