Struct std::io::SliceReader
A readable stream backed by an in-memory string slice.
Fields
Methods
impl SliceReader { ... }
-
fn new(slice: &[u8]) -> SliceReader
-
fn read(self: &mut SliceReader, buf: &mut [u8]) -> Result<usize>
Reads from the stream into a provided buffer.
If successful, returns the number of bytes read. This may be less than the size of the provided buffer.
-
fn fill_buffer(self: &mut SliceReader) -> Result<&[u8]>
Return the current contents of the buffer, reading additional data from the stream if necessary.
Does not move the internal buffer position.
-
fn consume(self: &mut SliceReader, amount: usize)
Mark
amount
bytes as consumed, moving the internal buffer position forward. -
fn seek(self: &mut SliceReader, whence: SeekFrom, offset: i64) -> Result<u64>
Jump to a specified position in the stream.
Returns the new position in the stream from the beginning.
-
fn position(self: &mut SliceReader) -> Result<u64>
Returns the current position in the stream from the beginning.
Mixins
impl SliceReader { ... }
-
mixin Seekable<SliceReader>
-
Rewind the stream to the beginning.
-
mixin Readable<SliceReader>
-
Fills the provided buffer by reading from the stream.
If stream had less bytes available than the size of the buffer, this method will return an
Error::eof()
. -
Reads the entire stream into a
StringBuf
.If successful, returns the number of bytes that were read.
-
mixin BufferedReadable<SliceReader>