ContentExtractor

Trait ContentExtractor 

Source
pub trait ContentExtractor: Send + Sync {
    // Required methods
    fn supported_types(&self) -> &[&str];
    fn extract<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<ExtractedContent, ExtractError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn can_extract(&self, path: &Path, mime_type: &str) -> bool { ... }
    fn can_extract_by_extension(&self, _path: &Path) -> bool { ... }
    fn extract_bytes<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _data: &'life1 [u8],
        _mime_type: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<ExtractedContent, ExtractError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Trait for extracting content from files.

Required Methods§

Source

fn supported_types(&self) -> &[&str]

Returns the MIME types this extractor can handle.

Source

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

Extract content from a file.

Provided Methods§

Source

fn can_extract(&self, path: &Path, mime_type: &str) -> bool

Check if this extractor can handle the given file.

Source

fn can_extract_by_extension(&self, _path: &Path) -> bool

Check if extractor can handle based on file extension.

Source

fn extract_bytes<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _data: &'life1 [u8], _mime_type: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<ExtractedContent, ExtractError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Extract content from bytes (for embedded content).

Implementors§