pub trait TranslationBackend: Send + Sync {
// Required method
fn translate_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
target: &'life2 Lang,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn id(&self) -> &'static str { ... }
fn supports(&self, target: &Lang) -> bool { ... }
}Expand description
A machine-translation backend for free-form text.
Implement this to plug a custom engine (e.g. a hosted translation API)
into the translation pipeline via set_backend.
The built-in offline backend (feature translation-offline) is used by
default when no custom backend is registered.
Inputs are English; implementations must return one translated string per input, preserving order. Inputs may contain multiple sentences.
Required Methods§
Sourcefn translate_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
target: &'life2 Lang,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn translate_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
target: &'life2 Lang,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Translate every English text into the target language, preserving order.
Provided Methods§
Sourcefn supports(&self, target: &Lang) -> bool
fn supports(&self, target: &Lang) -> bool
Whether this backend can translate into target.
The pipeline calls this before translate_batch;
when it returns false the free-form text is left untranslated (English)
instead of failing the request. Defaults to true (assume full support).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".