Files
byte-pusher-emu/src/misc/emulator_error.rs

33 lines
569 B
Rust
Raw Normal View History

use std::array::TryFromSliceError;
2024-02-17 09:54:41 +05:30
use std::fmt::Debug;
#[derive(Debug, Copy, Clone)]
2024-02-17 09:54:41 +05:30
pub enum DeviceType {
2024-02-18 22:03:21 +05:30
CPU,
2024-02-17 09:54:41 +05:30
RAM,
MMU,
2024-02-18 09:35:58 +05:30
/// Program counter
PC,
2024-02-17 09:54:41 +05:30
KEYBOARD,
AUDIO,
GRAPHICS,
}
#[derive(Debug, Clone)]
2024-02-17 09:54:41 +05:30
pub enum EmulatorError {
2024-02-17 11:22:26 +05:30
AllocationFailure(DeviceType, &'static str),
UnreachableMemory(DeviceType, u32),
InvalidColor(u8),
OtherError(String)
2024-02-17 09:54:41 +05:30
}
impl From<TryFromSliceError> for EmulatorError{
fn from(value: TryFromSliceError) -> Self {
EmulatorError::UnreachableMemory(DeviceType::RAM,0x5a5a)
}
}
2024-02-17 09:54:41 +05:30