pub struct UnifiedTranslationEngine { /* private fields */ }Expand description
统一的翻译引擎
合并了原来的翻译引擎和服务功能,提供简化的API和更好的性能。
Implementations§
Source§impl UnifiedTranslationEngine
impl UnifiedTranslationEngine
Sourcepub fn new(config: SimpleTranslationConfig) -> TranslationResult<Self>
pub fn new(config: SimpleTranslationConfig) -> TranslationResult<Self>
创建新的翻译引擎
Sourcepub async fn translate_text(&self, text: &str) -> TranslationResult<String>
pub async fn translate_text(&self, text: &str) -> TranslationResult<String>
翻译单个文本
Sourcepub async fn translate_texts(
&self,
texts: &[String],
) -> TranslationResult<Vec<String>>
pub async fn translate_texts( &self, texts: &[String], ) -> TranslationResult<Vec<String>>
翻译文本列表
Sourcepub async fn translate_dom_texts(
&self,
root: &dyn DomNode,
) -> TranslationResult<Vec<(String, String)>>
pub async fn translate_dom_texts( &self, root: &dyn DomNode, ) -> TranslationResult<Vec<(String, String)>>
从DOM节点收集并翻译文本
Sourcepub fn stats(&self) -> Arc<EngineStats>
pub fn stats(&self) -> Arc<EngineStats>
获取统计信息
Sourcepub fn config(&self) -> &SimpleTranslationConfig
pub fn config(&self) -> &SimpleTranslationConfig
获取配置
Sourcepub fn cleanup_cache(&self)
pub fn cleanup_cache(&self)
清理过期缓存
Sourcepub fn health_check(&self) -> EngineHealth
pub fn health_check(&self) -> EngineHealth
检查引擎健康状态
Auto Trait Implementations§
impl !Freeze for UnifiedTranslationEngine
impl !RefUnwindSafe for UnifiedTranslationEngine
impl Send for UnifiedTranslationEngine
impl Sync for UnifiedTranslationEngine
impl Unpin for UnifiedTranslationEngine
impl !UnwindSafe for UnifiedTranslationEngine
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
Mutably borrows from an owned value. Read more