Struct std::io::Cursor [] [src]

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

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

Cursors are typically used with memory buffer objects in order to allow Seek, Read, and Write implementations. For example, common cursor types include Cursor<Vec<u8>> and Cursor<&[u8]>.

Implementations of the I/O traits for Cursor<T> are currently not 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>

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

fn into_inner(self) -> T

Consumes this cursor, returning the underlying value.

fn get_ref(&self) -> &T

Gets a reference to the underlying value in this cursor.

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

Gets 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<usize>

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

fn by_ref(&mut self) -> &mut Self where Self: Sized

fn bytes(self) -> Bytes<Self> where Self: Sized

fn chars(self) -> Chars<Self> where Self: Sized

fn chain<R: Read>(self, next: R) -> Chain<Self, R> where Self: Sized

fn take(self, limit: u64) -> Take<Self> where Self: Sized

fn tee<W: Write>(self, out: W) -> Tee<Self, W> where Self: Sized

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<usize>

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

fn by_ref(&mut self) -> &mut Self where Self: Sized

fn bytes(self) -> Bytes<Self> where Self: Sized

fn chars(self) -> Chars<Self> where Self: Sized

fn chain<R: Read>(self, next: R) -> Chain<Self, R> where Self: Sized

fn take(self, limit: u64) -> Take<Self> where Self: Sized

fn tee<W: Write>(self, out: W) -> Tee<Self, W> where Self: Sized

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<usize>

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

fn by_ref(&mut self) -> &mut Self where Self: Sized

fn bytes(self) -> Bytes<Self> where Self: Sized

fn chars(self) -> Chars<Self> where Self: Sized

fn chain<R: Read>(self, next: R) -> Chain<Self, R> where Self: Sized

fn take(self, limit: u64) -> Take<Self> where Self: Sized

fn tee<W: Write>(self, out: W) -> Tee<Self, W> where Self: Sized

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<usize>

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

fn split(self, byte: u8) -> Split<Self> where Self: Sized

fn lines(self) -> Lines<Self> where Self: Sized

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<usize>

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

fn split(self, byte: u8) -> Split<Self> where Self: Sized

fn lines(self) -> Lines<Self> where Self: Sized

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<usize>

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

fn split(self, byte: u8) -> Split<Self> where Self: Sized

fn lines(self) -> Lines<Self> where Self: Sized

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<()>

fn by_ref(&mut self) -> &mut Self where Self: Sized

fn broadcast<W: Write>(self, other: W) -> Broadcast<Self, W> where Self: Sized

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<()>

fn by_ref(&mut self) -> &mut Self where Self: Sized

fn broadcast<W: Write>(self, other: W) -> Broadcast<Self, W> where Self: Sized

Derived Implementations

impl<T: Debug> Debug for Cursor<T> where T: Debug

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl<T: Clone> Clone for Cursor<T> where T: Clone

fn clone(&self) -> Cursor<T>

fn clone_from(&mut self, source: &Self)