pub trait Formatter: Sealed {
Show 29 methods
// Required methods
fn format(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput
);
fn options(&self) -> &FormatterOptions;
fn options_mut(&mut self) -> &mut FormatterOptions;
fn format_mnemonic_options(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput,
options: u32
);
fn operand_count(&mut self, instruction: &Instruction) -> u32;
fn op_access(
&mut self,
instruction: &Instruction,
operand: u32
) -> Result<Option<OpAccess>, IcedError>;
fn get_instruction_operand(
&mut self,
instruction: &Instruction,
operand: u32
) -> Result<Option<u32>, IcedError>;
fn get_formatter_operand(
&mut self,
instruction: &Instruction,
instruction_operand: u32
) -> Result<Option<u32>, IcedError>;
fn format_operand(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput,
operand: u32
) -> Result<(), IcedError>;
fn format_operand_separator(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput
);
fn format_all_operands(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput
);
fn format_register(&mut self, register: Register) -> &str;
fn format_i8(&mut self, value: i8) -> &str;
fn format_i16(&mut self, value: i16) -> &str;
fn format_i32(&mut self, value: i32) -> &str;
fn format_i64(&mut self, value: i64) -> &str;
fn format_u8(&mut self, value: u8) -> &str;
fn format_u16(&mut self, value: u16) -> &str;
fn format_u32(&mut self, value: u32) -> &str;
fn format_u64(&mut self, value: u64) -> &str;
fn format_i8_options(
&mut self,
value: i8,
number_options: &NumberFormattingOptions<'_>
) -> &str;
fn format_i16_options(
&mut self,
value: i16,
number_options: &NumberFormattingOptions<'_>
) -> &str;
fn format_i32_options(
&mut self,
value: i32,
number_options: &NumberFormattingOptions<'_>
) -> &str;
fn format_i64_options(
&mut self,
value: i64,
number_options: &NumberFormattingOptions<'_>
) -> &str;
fn format_u8_options(
&mut self,
value: u8,
number_options: &NumberFormattingOptions<'_>
) -> &str;
fn format_u16_options(
&mut self,
value: u16,
number_options: &NumberFormattingOptions<'_>
) -> &str;
fn format_u32_options(
&mut self,
value: u32,
number_options: &NumberFormattingOptions<'_>
) -> &str;
fn format_u64_options(
&mut self,
value: u64,
number_options: &NumberFormattingOptions<'_>
) -> &str;
// Provided method
fn format_mnemonic(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput
) { ... }
}
Expand description
Formats instructions
This trait is sealed and cannot be implemented by your own types.
Required Methods§
sourcefn format(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput
)
fn format( &mut self, instruction: &Instruction, output: &mut dyn FormatterOutput )
Formats the whole instruction: prefixes, mnemonic, operands
Arguments
instruction
: Instructionoutput
: Output, eg. aString
sourcefn options(&self) -> &FormatterOptions
fn options(&self) -> &FormatterOptions
Gets the formatter options (immutable)
sourcefn options_mut(&mut self) -> &mut FormatterOptions
fn options_mut(&mut self) -> &mut FormatterOptions
Gets the formatter options (mutable)
sourcefn format_mnemonic_options(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput,
options: u32
)
fn format_mnemonic_options( &mut self, instruction: &Instruction, output: &mut dyn FormatterOutput, options: u32 )
Formats the mnemonic and/or any prefixes
Arguments
instruction
: Instructionoutput
: Output, eg. aString
options
: Options, seeFormatMnemonicOptions
sourcefn operand_count(&mut self, instruction: &Instruction) -> u32
fn operand_count(&mut self, instruction: &Instruction) -> u32
Gets the number of operands that will be formatted. A formatter can add and remove operands
Arguments
instruction
: Instruction
sourcefn op_access(
&mut self,
instruction: &Instruction,
operand: u32
) -> Result<Option<OpAccess>, IcedError>
fn op_access( &mut self, instruction: &Instruction, operand: u32 ) -> Result<Option<OpAccess>, IcedError>
Returns the operand access but only if it’s an operand added by the formatter. If it’s an
operand that is part of Instruction
, you should call eg. InstructionInfoFactory::info()
.
Arguments
instruction
: Instructionoperand
: Operand number, 0-based. This is a formatter operand and isn’t necessarily the same as an instruction operand. Seeoperand_count()
Errors
This fails if operand
is invalid.
sourcefn get_instruction_operand(
&mut self,
instruction: &Instruction,
operand: u32
) -> Result<Option<u32>, IcedError>
fn get_instruction_operand( &mut self, instruction: &Instruction, operand: u32 ) -> Result<Option<u32>, IcedError>
Converts a formatter operand index to an instruction operand index. Returns None
if it’s an operand added by the formatter
Arguments
instruction
: Instructionoperand
: Operand number, 0-based. This is a formatter operand and isn’t necessarily the same as an instruction operand. Seeoperand_count()
Errors
This fails if operand
is invalid.
sourcefn get_formatter_operand(
&mut self,
instruction: &Instruction,
instruction_operand: u32
) -> Result<Option<u32>, IcedError>
fn get_formatter_operand( &mut self, instruction: &Instruction, instruction_operand: u32 ) -> Result<Option<u32>, IcedError>
sourcefn format_operand(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput,
operand: u32
) -> Result<(), IcedError>
fn format_operand( &mut self, instruction: &Instruction, output: &mut dyn FormatterOutput, operand: u32 ) -> Result<(), IcedError>
Formats an operand. This is a formatter operand and not necessarily a real instruction operand. A formatter can add and remove operands.
Arguments
instruction
: Instructionoutput
: Output, eg. aString
operand
: Operand number, 0-based. This is a formatter operand and isn’t necessarily the same as an instruction operand. Seeoperand_count()
Errors
This fails if operand
is invalid.
sourcefn format_operand_separator(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput
)
fn format_operand_separator( &mut self, instruction: &Instruction, output: &mut dyn FormatterOutput )
sourcefn format_all_operands(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput
)
fn format_all_operands( &mut self, instruction: &Instruction, output: &mut dyn FormatterOutput )
sourcefn format_register(&mut self, register: Register) -> &str
fn format_register(&mut self, register: Register) -> &str
sourcefn format_i16(&mut self, value: i16) -> &str
fn format_i16(&mut self, value: i16) -> &str
sourcefn format_i32(&mut self, value: i32) -> &str
fn format_i32(&mut self, value: i32) -> &str
sourcefn format_i64(&mut self, value: i64) -> &str
fn format_i64(&mut self, value: i64) -> &str
sourcefn format_u16(&mut self, value: u16) -> &str
fn format_u16(&mut self, value: u16) -> &str
sourcefn format_u32(&mut self, value: u32) -> &str
fn format_u32(&mut self, value: u32) -> &str
sourcefn format_u64(&mut self, value: u64) -> &str
fn format_u64(&mut self, value: u64) -> &str
sourcefn format_i8_options(
&mut self,
value: i8,
number_options: &NumberFormattingOptions<'_>
) -> &str
fn format_i8_options( &mut self, value: i8, number_options: &NumberFormattingOptions<'_> ) -> &str
sourcefn format_i16_options(
&mut self,
value: i16,
number_options: &NumberFormattingOptions<'_>
) -> &str
fn format_i16_options( &mut self, value: i16, number_options: &NumberFormattingOptions<'_> ) -> &str
sourcefn format_i32_options(
&mut self,
value: i32,
number_options: &NumberFormattingOptions<'_>
) -> &str
fn format_i32_options( &mut self, value: i32, number_options: &NumberFormattingOptions<'_> ) -> &str
sourcefn format_i64_options(
&mut self,
value: i64,
number_options: &NumberFormattingOptions<'_>
) -> &str
fn format_i64_options( &mut self, value: i64, number_options: &NumberFormattingOptions<'_> ) -> &str
sourcefn format_u8_options(
&mut self,
value: u8,
number_options: &NumberFormattingOptions<'_>
) -> &str
fn format_u8_options( &mut self, value: u8, number_options: &NumberFormattingOptions<'_> ) -> &str
sourcefn format_u16_options(
&mut self,
value: u16,
number_options: &NumberFormattingOptions<'_>
) -> &str
fn format_u16_options( &mut self, value: u16, number_options: &NumberFormattingOptions<'_> ) -> &str
sourcefn format_u32_options(
&mut self,
value: u32,
number_options: &NumberFormattingOptions<'_>
) -> &str
fn format_u32_options( &mut self, value: u32, number_options: &NumberFormattingOptions<'_> ) -> &str
sourcefn format_u64_options(
&mut self,
value: u64,
number_options: &NumberFormattingOptions<'_>
) -> &str
fn format_u64_options( &mut self, value: u64, number_options: &NumberFormattingOptions<'_> ) -> &str
Provided Methods§
sourcefn format_mnemonic(
&mut self,
instruction: &Instruction,
output: &mut dyn FormatterOutput
)
fn format_mnemonic( &mut self, instruction: &Instruction, output: &mut dyn FormatterOutput )
Formats the mnemonic and any prefixes
Arguments
instruction
: Instructionoutput
: Output, eg. aString