1use std::io::{Cursor, Read, Seek, SeekFrom};
2use std::path::PathBuf;
3use std::sync::Arc;
4
5#[derive(Debug, Clone)]
7pub enum Bios {
8 Memory(Option<PathBuf>, Cursor<Vec<u8>>),
10
11 File(PathBuf, Arc<std::fs::File>),
13}
14
15impl Read for Bios {
16 fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
17 match self {
18 Self::Memory(_, data) => data.read(buf),
19 Self::File(_, file) => file.read(buf),
20 }
21 }
22}
23
24impl Seek for Bios {
25 fn seek(&mut self, pos: SeekFrom) -> std::io::Result<u64> {
26 match self {
27 Self::Memory(_, data) => data.seek(pos),
28 Self::File(_, file) => file.seek(pos),
29 }
30 }
31}