riscv_analysis/reader/mod.rs
1use std::iter::Peekable;
2
3use uuid::Uuid;
4
5use crate::parser::Lexer;
6
7#[derive(Debug)]
8pub enum FileReaderError {
9 IOErr(String),
10 InternalFileNotFound,
11 FileAlreadyRead(String),
12 Unexpected,
13 InvalidPath,
14}
15
16pub trait FileReader: Sized {
17 /// Import and read a file into the reader
18 ///
19 /// Returns the UUID of the file and a peekable lexer. This lexer will allow
20 /// you to search the file. Each file has its own attached lexer.
21 fn import_file(
22 &mut self,
23 path: &str,
24 in_file: Option<uuid::Uuid>,
25 ) -> Result<(Uuid, Peekable<Lexer>), FileReaderError>;
26
27 fn get_filename(&self, uuid: uuid::Uuid) -> Option<String>;
28}