pub trait FileReader {
// Required methods
fn read_as_text(&self, file_path: &str) -> Result<String>;
fn can_handle(&self, extension: &str) -> bool;
// Provided methods
fn read_as_text_from_bytes(&self, _bytes: &[u8]) -> Result<String> { ... }
fn read_as_text_from_reader(&self, reader: Box<dyn Read>) -> Result<String> { ... }
}Expand description
Trait for reading different file types
Required Methods§
Sourcefn read_as_text(&self, file_path: &str) -> Result<String>
fn read_as_text(&self, file_path: &str) -> Result<String>
Read file content as text from a file path
Sourcefn can_handle(&self, extension: &str) -> bool
fn can_handle(&self, extension: &str) -> bool
Check if this reader can handle the given file extension
Provided Methods§
Sourcefn read_as_text_from_bytes(&self, _bytes: &[u8]) -> Result<String>
fn read_as_text_from_bytes(&self, _bytes: &[u8]) -> Result<String>
Read file content as text from bytes