Struct std::io::CursorUnstable [-] [+] [src]

pub struct Cursor<T> {
    // some fields omitted
}

A Cursor is a type which wraps another I/O object to provide a Seek implementation.

Cursors are currently typically used with memory buffer objects in order to allow Seek plus Read and Write implementations. For example, common cursor types include:

Implementations of the I/O traits for Cursor<T> are not currently generic over T itself. Instead, specific implementations are provided for various in-memory buffer types like Vec<u8> and &[u8].

Methods

impl<T> Cursor<T>

fn new(inner: T) -> Cursor<T>

Create a new cursor wrapping the provided underlying I/O object.

fn into_inner(self) -> T

Consume this cursor, returning the underlying value.

fn get_ref(&self) -> &T

Get a reference to the underlying value in this cursor.

fn get_mut(&mut self) -> &mut T

Get a mutable reference to the underlying value in this cursor.

Care should be taken to avoid modifying the internal I/O state of the underlying value as it may corrupt this cursor's position.

fn position(&self) -> u64

Returns the current value of this cursor

fn set_position(&mut self, pos: u64)

Sets the value of this cursor

Trait Implementations

impl<'a> Seek for Cursor<&'a [u8]>

fn seek(&mut self, style: SeekFrom) -> Result<u64>

impl<'a> Seek for Cursor<&'a mut [u8]>

fn seek(&mut self, style: SeekFrom) -> Result<u64>

impl Seek for Cursor<Vec<u8>>

fn seek(&mut self, style: SeekFrom) -> Result<u64>

impl<'a> Read for Cursor<&'a [u8]>

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<()>

fn read_to_string(&mut self, buf: &mut String) -> Result<()>

impl<'a> Read for Cursor<&'a mut [u8]>

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<()>

fn read_to_string(&mut self, buf: &mut String) -> Result<()>

impl Read for Cursor<Vec<u8>>

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<()>

fn read_to_string(&mut self, buf: &mut String) -> Result<()>

impl<'a> BufRead for Cursor<&'a [u8]>

fn fill_buf(&mut self) -> Result<&[u8]>

fn consume(&mut self, amt: usize)

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<()>

fn read_line(&mut self, buf: &mut String) -> Result<()>

impl<'a> BufRead for Cursor<&'a mut [u8]>

fn fill_buf(&mut self) -> Result<&[u8]>

fn consume(&mut self, amt: usize)

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<()>

fn read_line(&mut self, buf: &mut String) -> Result<()>

impl<'a> BufRead for Cursor<Vec<u8>>

fn fill_buf(&mut self) -> Result<&[u8]>

fn consume(&mut self, amt: usize)

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<()>

fn read_line(&mut self, buf: &mut String) -> Result<()>

impl<'a> Write for Cursor<&'a mut [u8]>

fn write(&mut self, data: &[u8]) -> Result<usize>

fn flush(&mut self) -> Result<()>

fn write_all(&mut self, buf: &[u8]) -> Result<()>

fn write_fmt(&mut self, fmt: Arguments) -> Result<()>

impl Write for Cursor<Vec<u8>>

fn write(&mut self, buf: &[u8]) -> Result<usize>

fn flush(&mut self) -> Result<()>

fn write_all(&mut self, buf: &[u8]) -> Result<()>

fn write_fmt(&mut self, fmt: Arguments) -> Result<()>