Struct x64asm::instruction::InstructionBuilder
source · pub struct InstructionBuilder { /* private fields */ }
Expand description
Creates an Instruction
object step by step.
Implementations§
source§impl InstructionBuilder
impl InstructionBuilder
sourcepub fn new(mnemonic: Mnemonic) -> Self
pub fn new(mnemonic: Mnemonic) -> Self
Creates an InstructionBuilder
object with an instruction with no
operands and no comment.
sourcepub fn with_operands(&mut self, operands: &[Operand]) -> &mut Self
pub fn with_operands(&mut self, operands: &[Operand]) -> &mut Self
Follows the instruction’s mnemonic with operands.
Example
let instruction = InstructionBuilder::new(Mov)
.with_operands(&[Register::Rax, Register::Rbx])
.create();
sourcepub fn with_comment(&mut self, comment: &str) -> &mut Self
pub fn with_comment(&mut self, comment: &str) -> &mut Self
Follows the instruction with a comment.
Example
let instruction = InstructionBuilder::new(Mov)
.with_comment("Mov instruction")
.create();
sourcepub fn create(&mut self) -> Instruction
pub fn create(&mut self) -> Instruction
Finishes building the instruction.
Returns an Instruction
object, which is the private field
self.instruction
of this structure.