Skip to main content

ReadOperations

Trait ReadOperations 

Source
pub trait ReadOperations: Send + Sync {
    // Required methods
    fn read_file(&self, absolute_path: &Path) -> Result<Vec<u8>>;
    fn file_size(&self, absolute_path: &Path) -> Result<u64>;
    fn detect_image_mime(
        &self,
        absolute_path: &Path,
    ) -> Result<Option<&'static str>>;
    fn read_text_file(&self, absolute_path: &Path) -> Result<String>;
}
Expand description

Pluggable operations for the read tool (matching pi’s ReadOperations). Override these to delegate file reading to remote systems (for example SSH).

Required Methods§

Source

fn read_file(&self, absolute_path: &Path) -> Result<Vec<u8>>

Read entire file as raw bytes.

Source

fn file_size(&self, absolute_path: &Path) -> Result<u64>

Get file size in bytes.

Source

fn detect_image_mime( &self, absolute_path: &Path, ) -> Result<Option<&'static str>>

Detect image MIME type from magic bytes. Returns None for non-images.

Source

fn read_text_file(&self, absolute_path: &Path) -> Result<String>

Read entire file as a UTF-8 string.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§