Struct buf_list::Cursor

source ·
pub struct Cursor<T> { /* private fields */ }
Expand description

A Cursor wraps an in-memory BufList and provides it with a Seek implementation.

Cursors allow BufLists to implement Read and BufRead, allowing a BufList to be used anywhere you might use a reader or writer that does actual I/O.

The cursor may either own or borrow a BufList: both Cursor<BufList> and Cursor<&BufList> are supported.

Optional features

Implementations§

Creates a new cursor wrapping the provided BufList.

Examples
use buf_list::{BufList, Cursor};

let cursor = Cursor::new(BufList::new());

Consumes this cursor, returning the underlying value.

Examples
use buf_list::{BufList, Cursor};

let cursor = Cursor::new(BufList::new());

let vec = cursor.into_inner();

Gets a reference to the underlying value in this cursor.

Examples
use buf_list::{BufList, Cursor};

let cursor = Cursor::new(BufList::new());

let reference = cursor.get_ref();

Returns the current position of this cursor.

Examples
use buf_list::{BufList, Cursor};
use std::io::prelude::*;
use std::io::SeekFrom;

let mut cursor = Cursor::new(BufList::from(&[1, 2, 3, 4, 5][..]));

assert_eq!(cursor.position(), 0);

cursor.seek(SeekFrom::Current(2)).unwrap();
assert_eq!(cursor.position(), 2);

cursor.seek(SeekFrom::Current(-1)).unwrap();
assert_eq!(cursor.position(), 1);

Sets the position of this cursor.

Examples
use buf_list::{BufList, Cursor};

let mut cursor = Cursor::new(BufList::from(&[1, 2, 3, 4, 5][..]));

assert_eq!(cursor.position(), 0);

cursor.set_position(2);
assert_eq!(cursor.position(), 2);

cursor.set_position(4);
assert_eq!(cursor.position(), 4);

Trait Implementations§

Attempt to return the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
Tells this buffer that amt bytes have been consumed from the buffer, so they should no longer be returned in calls to poll_read. Read more
Attempts to return the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
Tells this buffer that amt bytes have been consumed from the buffer, so they should no longer be returned in calls to poll_read. Read more
Attempt to read from the AsyncRead into buf. Read more
Attempt to read from the AsyncRead into bufs using vectored IO operations. Read more
Attempts to read from the AsyncRead into buf. Read more
Attempt to seek to an offset, in bytes, in a stream. Read more
Attempts to seek to an offset, in bytes, in a stream. Read more
Waits for a seek operation to complete. Read more
Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty. 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
🔬This is a nightly-only experimental API. (buf_read_has_data_left)
Check if the underlying Read has any data left to be 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 String 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
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Like read, except that it reads into a slice of buffers. Read more
Read the exact number of bytes required to fill buf. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. 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
🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
🔬This is a nightly-only experimental API. (read_buf)
Read the exact number of bytes required to fill cursor. 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 adapter which will chain this stream with another. Read more
Creates an adapter which will read at most limit bytes from it. Read more
Seek to an offset, in bytes, in a stream. Read more
Returns the current seek position from the start of the stream. Read more
Rewind to the beginning of a stream. Read more
🔬This is a nightly-only experimental API. (seek_stream_len)
Returns the length of this stream (in bytes). Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Reads all bytes into buf until the delimiter byte or EOF is reached. Read more
Reads all bytes until a newline (the 0xA byte) is reached, and append them to the provided buffer. Read more
Returns a stream of the contents of this reader split on the byte byte. Read more
Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty. 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
Returns a stream over the lines of this reader. This method is the async equivalent to BufRead::lines. Read more
Creates a new AsyncRead instance that chains this stream with next. Read more
Pulls some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Pulls some bytes from this source into the specified buffer, advancing the buffer’s internal cursor. Read more
Reads the exact number of bytes required to fill buf. Read more
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 in big-endian order from the underlying reader. Read more
Reads a signed 16-bit integer in big-endian order from the underlying reader. Read more
Reads an unsigned 32-bit integer in big-endian order from the underlying reader. Read more
Reads a signed 32-bit integer in big-endian order from the underlying reader. Read more
Reads an unsigned 64-bit integer in big-endian order from the underlying reader. Read more
Reads an signed 64-bit integer in big-endian order from the underlying reader. Read more
Reads an unsigned 128-bit integer in big-endian order from the underlying reader. Read more
Reads an signed 128-bit integer in big-endian order from the underlying reader. Read more
Reads an 32-bit floating point type in big-endian order from the underlying reader. Read more
Reads an 64-bit floating point type in big-endian order from the underlying reader. Read more
Reads an unsigned 16-bit integer in little-endian order from the underlying reader. Read more
Reads a signed 16-bit integer in little-endian order from the underlying reader. Read more
Reads an unsigned 32-bit integer in little-endian order from the underlying reader. Read more
Reads a signed 32-bit integer in little-endian order from the underlying reader. Read more
Reads an unsigned 64-bit integer in little-endian order from the underlying reader. Read more
Reads an signed 64-bit integer in little-endian order from the underlying reader. Read more
Reads an unsigned 128-bit integer in little-endian order from the underlying reader. Read more
Reads an signed 128-bit integer in little-endian order from the underlying reader. Read more
Reads an 32-bit floating point type in little-endian order from the underlying reader. Read more
Reads an 64-bit floating point type in little-endian order from the underlying reader. Read more
Reads all bytes until EOF in this source, placing them into buf. Read more
Reads all bytes until EOF in this source, appending them to buf. Read more
Creates an adaptor which reads at most limit bytes from it. Read more
Creates a future which will seek an IO object, and then yield the new position in the object and the object itself. Read more
Creates a future which will rewind to the beginning of the stream. Read more
Creates a future which will return the current seek position from the start of the stream. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.