pub struct InstructionBuilder { /* private fields */ }
Expand description
A builder pattern for Instructions that ensures they are always valid when instantiated.
Implementations§
Source§impl InstructionBuilder
impl InstructionBuilder
Sourcepub fn condition(self, cond: CondCode) -> Self
pub fn condition(self, cond: CondCode) -> Self
Sets the condition of an existing instruction to the chosen condition code. Can be chained with other methods.
Sourcepub fn argument(self, arg: Argument) -> Self
pub fn argument(self, arg: Argument) -> Self
Appends an argument to an existing instruction. Can be chained with other methods operating on InstructionBuilder.
Sourcepub fn update(self) -> Self
pub fn update(self) -> Self
Sets the s-bit of an existing instruction. Can be chained with other methods.
Sourcepub fn build(self) -> Result<Instruction, InstructionError>
pub fn build(self) -> Result<Instruction, InstructionError>
Attempts to build a valid, encodable instruction from the arguments in the InstructionBuilder. Will return an InstructionError on invalid instructions.
use cfd16_lib::prelude::*;
let wrong = InstructionBuilder::new(OpCode::Ret)
.argument(Argument::Reg(Register::B))
.build();
assert!(wrong.is_err());
Trait Implementations§
Source§impl Clone for InstructionBuilder
impl Clone for InstructionBuilder
Source§fn clone(&self) -> InstructionBuilder
fn clone(&self) -> InstructionBuilder
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 InstructionBuilder
impl Debug for InstructionBuilder
Source§impl Default for InstructionBuilder
impl Default for InstructionBuilder
Source§impl PartialEq for InstructionBuilder
impl PartialEq for InstructionBuilder
impl Eq for InstructionBuilder
impl StructuralPartialEq for InstructionBuilder
Auto Trait Implementations§
impl Freeze for InstructionBuilder
impl RefUnwindSafe for InstructionBuilder
impl Send for InstructionBuilder
impl Sync for InstructionBuilder
impl Unpin for InstructionBuilder
impl UnwindSafe for InstructionBuilder
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