pub trait ModelAdapter:
Send
+ Sync
+ Debug {
type Task: Task;
// Required methods
fn info(&self) -> AdapterInfo;
fn execute(
&self,
input: <Self::Task as Task>::Input,
config: Option<&<Self::Task as Task>::Config>,
) -> Result<<Self::Task as Task>::Output, OCRError>;
// Provided methods
fn supports_batching(&self) -> bool { ... }
fn recommended_batch_size(&self) -> usize { ... }
}Expand description
Core trait for model adapters.
Adapters bridge the gap between task interfaces and concrete model implementations. They handle model-specific preprocessing, inference, and postprocessing while conforming to the task’s typed input/output contract.
Required Associated Types§
Required Methods§
Sourcefn info(&self) -> AdapterInfo
fn info(&self) -> AdapterInfo
Returns information about this adapter.
Provided Methods§
Sourcefn supports_batching(&self) -> bool
fn supports_batching(&self) -> bool
Returns whether this adapter can handle batched inputs efficiently.
Sourcefn recommended_batch_size(&self) -> usize
fn recommended_batch_size(&self) -> usize
Returns the recommended batch size for this adapter.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".