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§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Stable format name, used for reporting and for Hit::anchor_kind.
Sourcefn extensions(&self) -> &'static [&'static str]
fn extensions(&self) -> &'static [&'static str]
Extensions handled, lower-case, without the dot.
fn extract( &self, name: &str, bytes: &[u8], ) -> Result<Option<Vec<ExtractedDocument>>>
Provided Methods§
Sourcefn sniff(&self, _bytes: &[u8]) -> bool
fn sniff(&self, _bytes: &[u8]) -> bool
Unambiguous content check, for files with a missing or wrong extension.
Sourcefn capabilities(&self) -> Capabilities
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.
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".