pub struct OptimizedTextCollector {
skip_tags: HashSet<&'static str>,
attribute_tags: HashMap<&'static str, &'static [&'static str]>,
work_queue: VecDeque<(Handle, u8)>,
}Expand description
优化的文本收集器
Fields§
跳过的标签集合(使用更快的查找)
收集属性文本的标签映射(使用静态字符串)
work_queue: VecDeque<(Handle, u8)>预分配的工作缓冲区
Implementations§
Source§impl OptimizedTextCollector
impl OptimizedTextCollector
Sourcepub fn collect_from_dom_optimized(
&mut self,
dom: &RcDom,
) -> TranslationResult<Vec<OptimizedTextItem>>
pub fn collect_from_dom_optimized( &mut self, dom: &RcDom, ) -> TranslationResult<Vec<OptimizedTextItem>>
从DOM中收集文本(优化版本)
Sourcefn process_node(
&mut self,
node: &Handle,
items: &mut Vec<OptimizedTextItem>,
depth: u8,
) -> TranslationResult<()>
fn process_node( &mut self, node: &Handle, items: &mut Vec<OptimizedTextItem>, depth: u8, ) -> TranslationResult<()>
处理单个节点(内联以提高性能)
Sourcefn is_translatable_text(&self, text: &str) -> bool
fn is_translatable_text(&self, text: &str) -> bool
快速检查文本是否可翻译
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OptimizedTextCollector
impl !RefUnwindSafe for OptimizedTextCollector
impl !Send for OptimizedTextCollector
impl !Sync for OptimizedTextCollector
impl Unpin for OptimizedTextCollector
impl !UnwindSafe for OptimizedTextCollector
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