pub trait Reranker: Send + Sync {
// Required methods
fn rerank_sync(
&self,
query: &str,
documents: &[RerankDocument],
) -> Result<Vec<RerankScore>, SearchError>;
fn id(&self) -> &str;
fn model_name(&self) -> &str;
// Provided methods
fn max_length(&self) -> usize { ... }
fn is_available(&self) -> bool { ... }
}Expand description
Synchronous reranking interface for host projects that call rerankers from non-async contexts.
Implement this trait for rerankers whose rerank operations are inherently
synchronous (e.g., blocking ONNX inference). The companion
SyncRerankerAdapter wraps any SyncRerank implementor into a full
async Reranker, suitable for use anywhere frankensearch expects one.
Required Methods§
Sourcefn rerank_sync(
&self,
query: &str,
documents: &[RerankDocument],
) -> Result<Vec<RerankScore>, SearchError>
fn rerank_sync( &self, query: &str, documents: &[RerankDocument], ) -> Result<Vec<RerankScore>, SearchError>
Synchronously rerank documents against a query.
Returns documents sorted by descending cross-encoder score.
§Errors
Returns SearchError when reranking fails (for example model load,
inference, or input validation failures).
Sourcefn model_name(&self) -> &str
fn model_name(&self) -> &str
Human-friendly reranker model name.
Provided Methods§
Sourcefn max_length(&self) -> usize
fn max_length(&self) -> usize
Maximum supported token length for query+document pair input.
Sourcefn is_available(&self) -> bool
fn is_available(&self) -> bool
Whether this reranker is loaded and ready for inference.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".