pub struct TransactionParser<'a> { /* private fields */ }Expand description
Streaming, callback-based transaction parser for no_std / zero-alloc use.
Instead of collecting inputs/outputs into a slice, this parser calls user- supplied closures for each element, allowing the caller to decide how to store or discard them.
let mut parser = TransactionParser::new(raw);
// parser.parse_with(|input| { ... }, |output| { ... });Implementations§
Source§impl<'a> TransactionParser<'a>
impl<'a> TransactionParser<'a>
Sourcepub fn new(data: &'a [u8]) -> Self
pub fn new(data: &'a [u8]) -> Self
Create a new parser positioned at the start of a raw transaction.
Sourcepub fn bytes_consumed(&self) -> usize
pub fn bytes_consumed(&self) -> usize
How many bytes have been consumed so far.
Call this after parse_with to advance an outer
cursor by exactly the number of bytes this transaction occupied.
Sourcepub fn parse_with<FI, FO>(
&mut self,
on_input: FI,
on_output: FO,
) -> ParseResult<(i32, u32, usize, usize)>
pub fn parse_with<FI, FO>( &mut self, on_input: FI, on_output: FO, ) -> ParseResult<(i32, u32, usize, usize)>
Parse the transaction, calling on_input for each input and
on_output for each output.
Witness data is skipped unless you need it (saves work for indexers).
Returns (version, locktime, input_count, output_count).
Auto Trait Implementations§
impl<'a> Freeze for TransactionParser<'a>
impl<'a> RefUnwindSafe for TransactionParser<'a>
impl<'a> Send for TransactionParser<'a>
impl<'a> Sync for TransactionParser<'a>
impl<'a> Unpin for TransactionParser<'a>
impl<'a> UnsafeUnpin for TransactionParser<'a>
impl<'a> UnwindSafe for TransactionParser<'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