pub struct ElementCounter { /* private fields */ }Expand description
count_elements fed in pieces, as a part inflates out of a zip (BILI-115): after the last piece and
ElementCounter::finish, ElementCounter::count is exactly what count_elements gives for the whole part,
and after any piece it is at most that (a start tag is counted only once its name has ended, a region is skipped
only once its opening is known), so a running total over several parts can refuse a file before the rest of it
is read without refusing one the whole-part count accepts. Memory is a few bytes whatever the input.
A part that starts as UTF-16 (count_elements transcodes those) is not counted: ElementCounter::exact is
then false, count stays 0 (below the real count, so still safe for an early refusal) and the caller counts
the whole part with count_elements instead.
Implementations§
Source§impl ElementCounter
impl ElementCounter
Sourcepub fn new(local: &str) -> ElementCounter
pub fn new(local: &str) -> ElementCounter
A counter of the start tags whose local name is local.
Sourcepub fn exact(&self) -> bool
pub fn exact(&self) -> bool
False when the part is UTF-16, which this counter leaves to count_elements.