pub struct ProcessorRegistry { /* private fields */ }Expand description
Registry of structured processors.
Thread-safe (processors are Arc<dyn Processor>) and can be shared
across threads via Arc<ProcessorRegistry>.
Implementations§
Source§impl ProcessorRegistry
impl ProcessorRegistry
Sourcepub fn with_builtins() -> Self
pub fn with_builtins() -> Self
Create a registry pre-populated with all built-in processors.
Sourcepub fn register(&mut self, processor: Arc<dyn Processor>)
pub fn register(&mut self, processor: Arc<dyn Processor>)
Register a processor. Overwrites any existing processor with the same name.
Sourcepub fn register_with_alias(
&mut self,
processor: Arc<dyn Processor>,
alias: &str,
)
pub fn register_with_alias( &mut self, processor: Arc<dyn Processor>, alias: &str, )
Register a processor under its canonical name and an additional alias.
Sourcepub fn find_processor(
&self,
content: &[u8],
profile: &FileTypeProfile,
) -> Option<&Arc<dyn Processor>>
pub fn find_processor( &self, content: &[u8], profile: &FileTypeProfile, ) -> Option<&Arc<dyn Processor>>
Find a processor that can handle the given content + profile.
- If the profile names a specific processor, look it up directly.
- Otherwise, iterate all processors and return the first whose
can_handlereturnstrue.
Returns None if no processor matches (caller should fall back
to the streaming scanner).
Sourcepub fn process(
&self,
content: &[u8],
profile: &FileTypeProfile,
store: &MappingStore,
) -> Result<Option<Vec<u8>>>
pub fn process( &self, content: &[u8], profile: &FileTypeProfile, store: &MappingStore, ) -> Result<Option<Vec<u8>>>
Process content using the matching processor.
Returns Ok(Some(output)) if a processor matched and succeeded,
Ok(None) if no processor matches (caller should fall back),
or Err(...) if processing failed.
§Errors
Returns the underlying processor’s error if processing fails.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ProcessorRegistry
impl !UnwindSafe for ProcessorRegistry
impl Freeze for ProcessorRegistry
impl Send for ProcessorRegistry
impl Sync for ProcessorRegistry
impl Unpin for ProcessorRegistry
impl UnsafeUnpin for ProcessorRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more