Skip to main content

FileProcessor

Trait FileProcessor 

Source
pub trait FileProcessor:
    Send
    + Sync
    + Debug {
    // Required methods
    fn process<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<ProcessingResult, ProcessingError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn supports_mime_type(&self, mime_type: &str) -> bool;
    fn provider_name(&self) -> &'static str;
}
Expand description

Trait for file processing providers.

Implementors of this trait can extract text content from various document formats. Each provider may support different file types and have different requirements (API keys, network access, etc.).

Required Methods§

Source

fn process<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<ProcessingResult, ProcessingError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Process a file and extract text content.

§Arguments
  • path - Path to the file to process
§Returns

A ProcessingResult containing the extracted content, or an error.

Source

fn supports_mime_type(&self, mime_type: &str) -> bool

Check if this processor supports the given MIME type.

§Arguments
  • mime_type - The MIME type to check (e.g., “application/pdf”)
§Returns

true if this processor can handle files of this type.

Source

fn provider_name(&self) -> &'static str

Get the provider name for logging and debugging.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§