pub struct TranslationConfig {Show 17 fields
pub source_language: String,
pub target_language: String,
pub api_url: String,
pub enable_cache: bool,
pub cache_ttl: Duration,
pub max_cache_entries: usize,
pub batch_size: usize,
pub max_retries: usize,
pub retry_delay_ms: u64,
pub timeout_seconds: u64,
pub use_indexing: bool,
pub min_text_length: usize,
pub skip_links: bool,
pub skip_code_blocks: bool,
pub custom_filters: Vec<String>,
pub api_key: Option<String>,
pub user_agent: String,
}Expand description
翻译配置结构体
Fields§
§source_language: String源语言代码 (ISO 639-1)
target_language: String目标语言代码 (ISO 639-1)
api_url: String翻译API的URL地址
enable_cache: bool是否启用缓存
cache_ttl: Duration缓存TTL (生存时间)
max_cache_entries: usize缓存最大条目数
batch_size: usize批处理大小
max_retries: usize最大重试次数
retry_delay_ms: u64重试延迟 (毫秒)
timeout_seconds: u64请求超时时间 (秒)
use_indexing: bool是否启用索引标记
min_text_length: usize最小翻译文本长度
skip_links: bool是否跳过链接文本
skip_code_blocks: bool是否跳过代码块
custom_filters: Vec<String>自定义过滤规则 (正则表达式)
api_key: Option<String>API认证密钥
user_agent: String用户代理字符串
Implementations§
Source§impl TranslationConfig
impl TranslationConfig
Sourcepub fn target_language(self, lang: &str) -> Self
pub fn target_language(self, lang: &str) -> Self
设置目标语言
Sourcepub fn source_language(self, lang: &str) -> Self
pub fn source_language(self, lang: &str) -> Self
设置源语言
Sourcepub fn enable_cache(self, enabled: bool) -> Self
pub fn enable_cache(self, enabled: bool) -> Self
启用或禁用缓存
Sourcepub fn batch_size(self, size: usize) -> Self
pub fn batch_size(self, size: usize) -> Self
设置批处理大小
Sourcepub fn max_retries(self, retries: usize) -> Self
pub fn max_retries(self, retries: usize) -> Self
设置最大重试次数
Sourcepub fn use_indexing(self, enabled: bool) -> Self
pub fn use_indexing(self, enabled: bool) -> Self
启用或禁用索引标记
Sourcepub fn min_text_length(self, length: usize) -> Self
pub fn min_text_length(self, length: usize) -> Self
设置最小翻译文本长度
Sourcepub fn add_filter(self, pattern: &str) -> Self
pub fn add_filter(self, pattern: &str) -> Self
添加自定义过滤规则
Sourcepub fn from_file<P: AsRef<Path>>(path: P) -> TranslationResult<Self>
pub fn from_file<P: AsRef<Path>>(path: P) -> TranslationResult<Self>
从文件加载配置
Sourcepub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> TranslationResult<()>
pub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> TranslationResult<()>
保存配置到文件
Sourcepub fn validate(&self) -> TranslationResult<()>
pub fn validate(&self) -> TranslationResult<()>
验证配置的有效性
Sourcepub fn http_timeout(&self) -> Duration
pub fn http_timeout(&self) -> Duration
获取HTTP客户端超时时间
Sourcepub fn retry_delay(&self) -> Duration
pub fn retry_delay(&self) -> Duration
获取重试延迟时间
Trait Implementations§
Source§impl Clone for TranslationConfig
impl Clone for TranslationConfig
Source§fn clone(&self) -> TranslationConfig
fn clone(&self) -> TranslationConfig
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TranslationConfig
impl Debug for TranslationConfig
Source§impl Default for TranslationConfig
impl Default for TranslationConfig
Source§impl<'de> Deserialize<'de> for TranslationConfig
impl<'de> Deserialize<'de> for TranslationConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TranslationConfig
impl RefUnwindSafe for TranslationConfig
impl Send for TranslationConfig
impl Sync for TranslationConfig
impl Unpin for TranslationConfig
impl UnwindSafe for TranslationConfig
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