pub struct ComplexPropertyBudget { /* private fields */ }Expand description
The walk state every IfcComplexProperty walker charges: member visits for
the current top-level property, output bytes for the whole model
(complex_property_output_budget), and how many levels it cut.
Check order, identical in every copy, and every charge is made HERE so the
copies cannot drift: Self::listing for each listing a set makes;
within a first listing’s walk, Self::admit_member before reading a
member, Self::member_part once the member is read (charges its entry,
and its part when it has a display), and Self::level_value once the
level’s members are done (charges the joined value, and only a value that
has parts).
Implementations§
Source§impl ComplexPropertyBudget
impl ComplexPropertyBudget
Sourcepub fn for_input(input_bytes: usize) -> Self
pub fn for_input(input_bytes: usize) -> Self
The budget of one model whose source is input_bytes long.
Sourcepub fn listing<V: Clone>(
&mut self,
memo: &mut HashMap<u32, (V, usize)>,
id: u32,
resolve: impl FnOnce(&mut Self) -> (V, usize),
spent: impl FnOnce() -> V,
) -> V
pub fn listing<V: Clone>( &mut self, memo: &mut HashMap<u32, (V, usize)>, id: u32, resolve: impl FnOnce(&mut Self) -> (V, usize), spent: impl FnOnce() -> V, ) -> V
One listing of complex property id by a set. The first listing of an
id calls resolve, which starts the property and walks it against
this budget, and returns the value with its
complex_property_listing_bytes; memo keeps both. A later listing
reuses the value, charged its listing bytes, or reads spent() (a
counted cut) once the budget is spent. Memoised per id, not per
listing: a repeat costs what it keeps, not a fresh walk.
A repeat listing is admitted while any budget is left and charged in full, so one admitted with almost nothing left overshoots: the total stays under the budget plus one listing.
Sourcepub fn start_property(&mut self)
pub fn start_property(&mut self)
Start a top-level property: its member visits start at zero, the byte budget carries on.
Sourcepub fn admit_member(&mut self) -> bool
pub fn admit_member(&mut self) -> bool
Whether one more member may be read, counting it if so.
Sourcepub fn member_part(&mut self, name: &str, display: &str) -> Option<String>
pub fn member_part(&mut self, name: &str, display: &str) -> Option<String>
A member that was read, under name (empty without one) with
display (empty when it has no value): charge its entry, and return
the "Name: value" part (bare value without a name), charged too,
or None when there is no display to show. A member without a name is
still read for its value, in every copy.
Sourcepub fn level_value(&mut self, parts: &[String], cut: bool) -> Option<String>
pub fn level_value(&mut self, parts: &[String], cut: bool) -> Option<String>
A level’s value from its parts, cut when Self::admit_member
refused one of its members: the parts joined with ", " (then the
budget marker when cut), the bare marker when cut with no parts, or
None (the caller’s bare UsageName) when nothing resolved. Only a
value with parts is charged; the bare marker is bounded by the members
admitted to reach it.
Trait Implementations§
Source§impl Clone for ComplexPropertyBudget
impl Clone for ComplexPropertyBudget
Source§fn clone(&self) -> ComplexPropertyBudget
fn clone(&self) -> ComplexPropertyBudget
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more