pub struct ScriptChunk {
pub op: u8,
pub data: Option<Vec<u8>>,
}Expand description
A representation of a chunk of a script, which includes an opcode. For push operations, the associated data to push onto the stack is also included.
Fields§
§op: u8The opcode value
data: Option<Vec<u8>>Data for push operations (None for non-push ops)
Implementations§
Source§impl ScriptChunk
impl ScriptChunk
Sourcepub fn new_opcode(op: u8) -> Self
pub fn new_opcode(op: u8) -> Self
Creates a new opcode-only chunk (no data).
Sourcepub fn new_push(data: Vec<u8>) -> Self
pub fn new_push(data: Vec<u8>) -> Self
Creates a new data push chunk.
The appropriate opcode is determined based on the data length:
- 0 bytes: OP_0
- 1-75 bytes: direct push (opcode = length)
- 76-255 bytes: OP_PUSHDATA1
- 256-65535 bytes: OP_PUSHDATA2
- Larger: OP_PUSHDATA4
Sourcepub fn new(op: u8, data: Option<Vec<u8>>) -> Self
pub fn new(op: u8, data: Option<Vec<u8>>) -> Self
Creates a chunk from an opcode and optional data.
Sourcepub fn is_push_data(&self) -> bool
pub fn is_push_data(&self) -> bool
Returns true if this chunk is a data push operation.
Trait Implementations§
Source§impl Clone for ScriptChunk
impl Clone for ScriptChunk
Source§fn clone(&self) -> ScriptChunk
fn clone(&self) -> ScriptChunk
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScriptChunk
impl Debug for ScriptChunk
Source§impl Default for ScriptChunk
impl Default for ScriptChunk
Source§impl PartialEq for ScriptChunk
impl PartialEq for ScriptChunk
impl Eq for ScriptChunk
impl StructuralPartialEq for ScriptChunk
Auto Trait Implementations§
impl Freeze for ScriptChunk
impl RefUnwindSafe for ScriptChunk
impl Send for ScriptChunk
impl Sync for ScriptChunk
impl Unpin for ScriptChunk
impl UnsafeUnpin for ScriptChunk
impl UnwindSafe for ScriptChunk
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