Skip to main content

Task

Trait Task 

Source
pub trait Task:
    Send
    + Sync
    + Debug {
    type Config: Send + Sync + Debug + Clone;
    type Input: Send + Sync + Debug;
    type Output: Send + Sync + Debug;

    // Required methods
    fn task_type(&self) -> TaskType;
    fn schema(&self) -> TaskSchema;
    fn validate_input(&self, input: &Self::Input) -> Result<(), OCRError>;
    fn validate_output(&self, output: &Self::Output) -> Result<(), OCRError>;
    fn empty_output(&self) -> Self::Output;

    // Provided method
    fn description(&self) -> String { ... }
}
Expand description

Core trait for OCR tasks.

Tasks represent distinct operations in the OCR pipeline (detection, recognition, etc.). Each task defines its input/output schema and can be executed with various model adapters.

Required Associated Types§

Source

type Config: Send + Sync + Debug + Clone

Configuration type for this task

Source

type Input: Send + Sync + Debug

Input type for this task

Source

type Output: Send + Sync + Debug

Output type from this task

Required Methods§

Source

fn task_type(&self) -> TaskType

Returns the task type identifier.

Source

fn schema(&self) -> TaskSchema

Returns the schema defining inputs and outputs for this task.

Source

fn validate_input(&self, input: &Self::Input) -> Result<(), OCRError>

Validates that the given input is suitable for this task.

§Arguments
  • input - The input to validate
§Returns

Result indicating success or validation error

Source

fn validate_output(&self, output: &Self::Output) -> Result<(), OCRError>

Validates that the given output matches the expected schema.

§Arguments
  • output - The output to validate
§Returns

Result indicating success or validation error

Source

fn empty_output(&self) -> Self::Output

Returns an empty output instance for when no valid results are produced.

Provided Methods§

Source

fn description(&self) -> String

Returns a human-readable description of this task.

Implementors§

Source§

impl Task for DocumentOrientationTask

Source§

impl Task for DocumentRectificationTask

Source§

impl Task for FormulaRecognitionTask

Source§

impl Task for LayoutDetectionTask

Source§

impl Task for SealTextDetectionTask

Source§

impl Task for TableCellDetectionTask

Source§

impl Task for TableClassificationTask

Source§

impl Task for TableStructureRecognitionTask

Source§

impl Task for TextDetectionTask

Source§

impl Task for TextLineOrientationTask

Source§

impl Task for TextRecognitionTask