docs: make Intel400xComponentBehavior trait examples testable
This commit is contained in:
parent
6e245b615e
commit
9d328ee87b
1 changed files with 35 additions and 6 deletions
|
|
@ -592,10 +592,11 @@ pub enum Intel400xEvent {
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,ignore
|
/// ```rust
|
||||||
/// use std::time::Duration;
|
/// use std::time::Duration;
|
||||||
/// use rusty_emu::components::common::intel_400x::{
|
/// use rusty_emu::components::common::intel_400x::{
|
||||||
/// Intel400xComponentBehavior, Intel400xComponentType, Intel400xUnifiedState
|
/// Intel400xComponentBehavior, Intel400xComponentType, Intel400xUnifiedState,
|
||||||
|
/// Intel400xEvent
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// struct MyCustomComponent {
|
/// struct MyCustomComponent {
|
||||||
|
|
@ -619,7 +620,23 @@ pub enum Intel400xEvent {
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// // ... implement other methods
|
/// fn on_state_exit(&mut self, _state: Intel400xUnifiedState) {
|
||||||
|
/// // Cleanup when exiting a state
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn handle_component_event(&mut self, _event: Intel400xEvent) -> bool {
|
||||||
|
/// // Return true to handle event, false to let state machine process it
|
||||||
|
/// false
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn execute_state_logic(&mut self, _state: Intel400xUnifiedState) {
|
||||||
|
/// // Execute state-specific logic
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn responds_to_address(&self) -> bool {
|
||||||
|
/// // Most components respond to address transmission
|
||||||
|
/// true
|
||||||
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub trait Intel400xComponentBehavior {
|
pub trait Intel400xComponentBehavior {
|
||||||
|
|
@ -646,7 +663,10 @@ pub trait Intel400xComponentBehavior {
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,ignore
|
/// ```rust,no_run
|
||||||
|
/// use rusty_emu::components::common::intel_400x::Intel400xUnifiedState;
|
||||||
|
/// # struct MyComponent { address_high_nibble: Option<u8>, address_low_nibble: Option<u8> }
|
||||||
|
/// # impl MyComponent {
|
||||||
/// fn on_state_entry(&mut self, state: Intel400xUnifiedState) {
|
/// fn on_state_entry(&mut self, state: Intel400xUnifiedState) {
|
||||||
/// match state {
|
/// match state {
|
||||||
/// Intel400xUnifiedState::AddressPhase => {
|
/// Intel400xUnifiedState::AddressPhase => {
|
||||||
|
|
@ -656,11 +676,12 @@ pub trait Intel400xComponentBehavior {
|
||||||
/// }
|
/// }
|
||||||
/// Intel400xUnifiedState::DriveData => {
|
/// Intel400xUnifiedState::DriveData => {
|
||||||
/// // Prepare data for output
|
/// // Prepare data for output
|
||||||
/// self.prepare_output_data();
|
/// // self.prepare_output_data();
|
||||||
/// }
|
/// }
|
||||||
/// _ => {}
|
/// _ => {}
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
fn on_state_entry(&mut self, state: Intel400xUnifiedState);
|
fn on_state_entry(&mut self, state: Intel400xUnifiedState);
|
||||||
|
|
||||||
|
|
@ -704,7 +725,14 @@ pub trait Intel400xComponentBehavior {
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,ignore
|
/// ```rust,no_run
|
||||||
|
/// use rusty_emu::components::common::intel_400x::Intel400xUnifiedState;
|
||||||
|
/// # struct MyComponent { current_address: u16 }
|
||||||
|
/// # impl MyComponent {
|
||||||
|
/// # fn read_data_bus(&self) -> u8 { 0 }
|
||||||
|
/// # fn latch_address_nibble(&mut self, _nibble: u8) {}
|
||||||
|
/// # fn read_memory(&self, _addr: u16) -> u8 { 0 }
|
||||||
|
/// # fn write_data_bus(&self, _data: u8) {}
|
||||||
/// fn execute_state_logic(&mut self, state: Intel400xUnifiedState) {
|
/// fn execute_state_logic(&mut self, state: Intel400xUnifiedState) {
|
||||||
/// match state {
|
/// match state {
|
||||||
/// Intel400xUnifiedState::AddressPhase => {
|
/// Intel400xUnifiedState::AddressPhase => {
|
||||||
|
|
@ -720,6 +748,7 @@ pub trait Intel400xComponentBehavior {
|
||||||
/// _ => {}
|
/// _ => {}
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
fn execute_state_logic(&mut self, state: Intel400xUnifiedState);
|
fn execute_state_logic(&mut self, state: Intel400xUnifiedState);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue