Struct bdk_chain::bitcoin::io::Cursor

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

Wraps an in memory reader providing the position function.

Implementations§

§

impl<T> Cursor<T>
where T: AsRef<[u8]>,

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

Creates a Cursor by wrapping inner.

pub fn position(&self) -> u64

Returns the position read up to thus far.

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

Sets the internal position.

This method allows seeking within the wrapped memory by setting the position.

Note that setting a position that is larger than the buffer length will cause reads to return no bytes (EOF).

pub fn into_inner(self) -> T

Returns the inner buffer.

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

pub fn inner(&self) -> &T

Returns a reference to the inner buffer.

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

Trait Implementations§

§

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

§

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

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

fn consume(&mut self, amount: usize)

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

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

§

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

Reads bytes from source into buf.
§

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

Reads bytes from source until buf is full.
§

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

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

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

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

§

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

§

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

Reads a 64-bit unsigned integer.
§

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

Reads a 32-bit unsigned integer.
§

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

Reads a 16-bit unsigned integer.
§

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

Reads a 64-bit signed integer.
§

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

Reads a 32-bit signed integer.
§

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

Reads a 16-bit signed integer.
§

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

Reads an 8-bit unsigned integer.
§

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

Reads an 8-bit signed integer.
§

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

Reads a boolean.
§

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

Reads a byte slice.
source§

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

§

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

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V