Trait Formatter

Source
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§

Source

fn format( &mut self, instruction: &Instruction, output: &mut dyn FormatterOutput, )

Formats the whole instruction: prefixes, mnemonic, operands

§Arguments
  • instruction: Instruction
  • output: Output, eg. a String
Source

fn options(&self) -> &FormatterOptions

Gets the formatter options (immutable)

Source

fn options_mut(&mut self) -> &mut FormatterOptions

Gets the formatter options (mutable)

Source

fn format_mnemonic_options( &mut self, instruction: &Instruction, output: &mut dyn FormatterOutput, options: u32, )

Formats the mnemonic and/or any prefixes

§Arguments
Source

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
Source

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: Instruction
  • operand: Operand number, 0-based. This is a formatter operand and isn’t necessarily the same as an instruction operand. See operand_count()
§Errors

This fails if operand is invalid.

Source

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: Instruction
  • operand: Operand number, 0-based. This is a formatter operand and isn’t necessarily the same as an instruction operand. See operand_count()
§Errors

This fails if operand is invalid.

Source

fn get_formatter_operand( &mut self, instruction: &Instruction, instruction_operand: u32, ) -> Result<Option<u32>, IcedError>

Converts an instruction operand index to a formatter operand index. Returns None if the instruction operand isn’t used by the formatter

§Arguments
  • instruction: Instruction
  • instruction_operand: Instruction operand
§Errors

This fails if instruction_operand is invalid.

Source

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: Instruction
  • output: Output, eg. a String
  • operand: Operand number, 0-based. This is a formatter operand and isn’t necessarily the same as an instruction operand. See operand_count()
§Errors

This fails if operand is invalid.

Source

fn format_operand_separator( &mut self, instruction: &Instruction, output: &mut dyn FormatterOutput, )

Formats an operand separator

§Arguments
  • instruction: Instruction
  • output: Output, eg. a String
Source

fn format_all_operands( &mut self, instruction: &Instruction, output: &mut dyn FormatterOutput, )

Formats all operands

§Arguments
  • instruction: Instruction
  • output: Output, eg. a String
Source

fn format_register(&mut self, register: Register) -> &str

Formats a register

§Arguments
  • register: Register
Source

fn format_i8(&mut self, value: i8) -> &str

Formats a i8

§Arguments
  • value: Value
Source

fn format_i16(&mut self, value: i16) -> &str

Formats a i16

§Arguments
  • value: Value
Source

fn format_i32(&mut self, value: i32) -> &str

Formats a i32

§Arguments
  • value: Value
Source

fn format_i64(&mut self, value: i64) -> &str

Formats a i64

§Arguments
  • value: Value
Source

fn format_u8(&mut self, value: u8) -> &str

Formats a u8

§Arguments
  • value: Value
Source

fn format_u16(&mut self, value: u16) -> &str

Formats a u16

§Arguments
  • value: Value
Source

fn format_u32(&mut self, value: u32) -> &str

Formats a u32

§Arguments
  • value: Value
Source

fn format_u64(&mut self, value: u64) -> &str

Formats a u64

§Arguments
  • value: Value
Source

fn format_i8_options( &mut self, value: i8, number_options: &NumberFormattingOptions<'_>, ) -> &str

Formats a i8

§Arguments
  • value: Value
  • number_options: Options
Source

fn format_i16_options( &mut self, value: i16, number_options: &NumberFormattingOptions<'_>, ) -> &str

Formats a i16

§Arguments
  • value: Value
  • number_options: Options
Source

fn format_i32_options( &mut self, value: i32, number_options: &NumberFormattingOptions<'_>, ) -> &str

Formats a i32

§Arguments
  • value: Value
  • number_options: Options
Source

fn format_i64_options( &mut self, value: i64, number_options: &NumberFormattingOptions<'_>, ) -> &str

Formats a i64

§Arguments
  • value: Value
  • number_options: Options
Source

fn format_u8_options( &mut self, value: u8, number_options: &NumberFormattingOptions<'_>, ) -> &str

Formats a u8

§Arguments
  • value: Value
  • number_options: Options
Source

fn format_u16_options( &mut self, value: u16, number_options: &NumberFormattingOptions<'_>, ) -> &str

Formats a u16

§Arguments
  • value: Value
  • number_options: Options
Source

fn format_u32_options( &mut self, value: u32, number_options: &NumberFormattingOptions<'_>, ) -> &str

Formats a u32

§Arguments
  • value: Value
  • number_options: Options
Source

fn format_u64_options( &mut self, value: u64, number_options: &NumberFormattingOptions<'_>, ) -> &str

Formats a u64

§Arguments
  • value: Value
  • number_options: Options

Provided Methods§

Source

fn format_mnemonic( &mut self, instruction: &Instruction, output: &mut dyn FormatterOutput, )

Formats the mnemonic and any prefixes

§Arguments
  • instruction: Instruction
  • output: Output, eg. a String

Implementors§