Struct std::io::Cursor
[−]
[src]
pub struct Cursor<T> { // some fields omitted }
A Cursor
`Cursoris a type which wraps a non-I/O object to provide a
` is a type which wraps a non-I/O object to provide a Seek
`Seek`
implementation.
Cursors are typically used with memory buffer objects in order to allow
Seek
`Seek,
`, Read
`Read, and
`, and Write
`Writeimplementations. For example, common cursor types include
` implementations. For example, common cursor types
include Cursor<Vec<u8>>
`Cursorand
` and Cursor<&[u8]>
`Cursor<&[u8]>`.
Implementations of the I/O traits for Cursor<T>
`Cursorare currently not generic over
` are currently not generic
over T
`Titself. Instead, specific implementations are provided for various in-memory buffer types like
` itself. Instead, specific implementations are provided for various
in-memory buffer types like Vec<u8>
`Vecand
` and &[u8]
`&[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