Skip to main content

Extractor

Trait Extractor 

Source
pub trait Extractor: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn extensions(&self) -> &'static [&'static str];
    fn extract(
        &self,
        name: &str,
        bytes: &[u8],
    ) -> Result<Option<Vec<ExtractedDocument>>>;

    // Provided methods
    fn sniff(&self, _bytes: &[u8]) -> bool { ... }
    fn capabilities(&self) -> Capabilities { ... }
    fn can_handle(&self, name: &str, bytes: &[u8]) -> bool { ... }
}
Expand description

A format handler.

extract must either return text it actually decoded or Ok(None). It must not fall back to treating arbitrary bytes as text.

Required Methods§

Source

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

Stable format name, used for reporting and for Hit::anchor_kind.

Source

fn extensions(&self) -> &'static [&'static str]

Extensions handled, lower-case, without the dot.

Source

fn extract( &self, name: &str, bytes: &[u8], ) -> Result<Option<Vec<ExtractedDocument>>>

Provided Methods§

Source

fn sniff(&self, _bytes: &[u8]) -> bool

Unambiguous content check, for files with a missing or wrong extension.

Source

fn capabilities(&self) -> Capabilities

Resource and safety capabilities of this extractor.

The extraction pipeline enforces max_file_bytes before calling extract, wraps the call in a 5-second timeout, and respects thread_safe when deciding on parallelism.

Source

fn can_handle(&self, name: &str, bytes: &[u8]) -> bool

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§