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