Cursor

Struct Cursor 

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

Emulation of std::io::Cursor

This is not exported to bindings users as serialization is done via a bindings-specific pipeline.

Implementations§

Source§

impl<T> Cursor<T>

Source

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

Creates a Cursor by wrapping inner.

Source

pub fn position(&self) -> u64

Returns the position read up to thus far.

Source

pub fn into_inner(self) -> T

Returns the inner buffer.

This is the whole wrapped buffer, including the bytes already read.

Source

pub fn get_ref(&self) -> &T

Gets a reference to the underlying value in this cursor.

Source

pub 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.

Source

pub fn set_position(&mut self, pos: u64)

Sets the position of this cursor.

Trait Implementations§

Source§

impl<T: AsRef<[u8]>> BufRead for Cursor<T>

Source§

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

Returns data read from this reader, filling the internal buffer if needed.
Source§

fn consume(&mut self, amt: usize)

Marks the buffered data up to amount as consumed. Read more
Source§

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

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for Cursor<T>

Source§

fn default() -> Cursor<T>

Returns the “default value” for a type. Read more
Source§

impl<T: PartialEq> PartialEq for Cursor<T>

Source§

fn eq(&self, other: &Cursor<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: AsRef<[u8]>> Read for Cursor<T>

Source§

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

Reads bytes from source into buf.
Source§

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

Reads bytes from source until buf is full.
Source§

fn take(&mut self, limit: u64) -> Take<'_, Self>

Creates an adapter which will read at most limit bytes.
Source§

fn read_to_limit( &mut self, buf: &mut Vec<u8>, limit: u64, ) -> Result<usize, Error>

Attempts to read up to limit bytes from the reader, allocating space in buf as needed. Read more
Source§

impl<T: Eq> Eq for Cursor<T>

Source§

impl<T> StructuralPartialEq for Cursor<T>

Auto Trait Implementations§

§

impl<T> Freeze for Cursor<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Cursor<T>
where T: RefUnwindSafe,

§

impl<T> Send for Cursor<T>
where T: Send,

§

impl<T> Sync for Cursor<T>
where T: Sync,

§

impl<T> Unpin for Cursor<T>
where T: Unpin,

§

impl<T> UnwindSafe for Cursor<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<R> ReadExt for R
where R: Read + ?Sized,

Source§

fn read_u64(&mut self) -> Result<u64, Error>

Reads a 64-bit unsigned integer.
Source§

fn read_u32(&mut self) -> Result<u32, Error>

Reads a 32-bit unsigned integer.
Source§

fn read_u16(&mut self) -> Result<u16, Error>

Reads a 16-bit unsigned integer.
Source§

fn read_i64(&mut self) -> Result<i64, Error>

Reads a 64-bit signed integer.
Source§

fn read_i32(&mut self) -> Result<i32, Error>

Reads a 32-bit signed integer.
Source§

fn read_i16(&mut self) -> Result<i16, Error>

Reads a 16-bit signed integer.
Source§

fn read_u8(&mut self) -> Result<u8, Error>

Reads an 8-bit unsigned integer.
Source§

fn read_i8(&mut self) -> Result<i8, Error>

Reads an 8-bit signed integer.
Source§

fn read_bool(&mut self) -> Result<bool, Error>

Reads a boolean.
Source§

fn read_slice(&mut self, slice: &mut [u8]) -> Result<(), Error>

Reads a byte slice.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.