pub struct BsvReader<'a> { /* private fields */ }Expand description
A cursor-based reader for Bitcoin protocol binary data.
Wraps a byte slice and maintains a read position, providing methods to read fixed-size integers and VarInt values in little-endian order.
Implementations§
Source§impl<'a> BsvReader<'a>
impl<'a> BsvReader<'a>
Sourcepub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8], PrimitivesError>
pub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8], PrimitivesError>
Sourcepub fn read_u8(&mut self) -> Result<u8, PrimitivesError>
pub fn read_u8(&mut self) -> Result<u8, PrimitivesError>
Read a single byte and advance the position.
§Returns
The byte value, or an error if no data remains.
Sourcepub fn read_u16_le(&mut self) -> Result<u16, PrimitivesError>
pub fn read_u16_le(&mut self) -> Result<u16, PrimitivesError>
Read a little-endian u16 and advance the position by 2 bytes.
§Returns
The decoded u16, or an error if insufficient data.
Sourcepub fn read_u32_le(&mut self) -> Result<u32, PrimitivesError>
pub fn read_u32_le(&mut self) -> Result<u32, PrimitivesError>
Read a little-endian u32 and advance the position by 4 bytes.
§Returns
The decoded u32, or an error if insufficient data.
Sourcepub fn read_u64_le(&mut self) -> Result<u64, PrimitivesError>
pub fn read_u64_le(&mut self) -> Result<u64, PrimitivesError>
Read a little-endian u64 and advance the position by 8 bytes.
§Returns
The decoded u64, or an error if insufficient data.
Sourcepub fn read_varint(&mut self) -> Result<VarInt, PrimitivesError>
pub fn read_varint(&mut self) -> Result<VarInt, PrimitivesError>
Read a VarInt and advance the position accordingly.
§Returns
The decoded VarInt, or an error if insufficient data.
Auto Trait Implementations§
impl<'a> Freeze for BsvReader<'a>
impl<'a> RefUnwindSafe for BsvReader<'a>
impl<'a> Send for BsvReader<'a>
impl<'a> Sync for BsvReader<'a>
impl<'a> Unpin for BsvReader<'a>
impl<'a> UnsafeUnpin for BsvReader<'a>
impl<'a> UnwindSafe for BsvReader<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more