ComplexPropertyBudget

Struct ComplexPropertyBudget 

Source
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

Source

pub fn new(output_bytes: usize) -> Self

A scope that may build output_bytes of text.

Source

pub fn for_input(input_bytes: usize) -> Self

The budget of one model whose source is input_bytes long.

Source

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.

Source

pub fn start_property(&mut self)

Start a top-level property: its member visits start at zero, the byte budget carries on.

Source

pub fn admit_member(&mut self) -> bool

Whether one more member may be read, counting it if so.

Source

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.

Source

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.

Source

pub fn cuts(&self) -> usize

Levels and listings this budget has cut so far (D3: counted, and logged by the walk’s owner, never silent).

Trait Implementations§

Source§

impl Clone for ComplexPropertyBudget

Source§

fn clone(&self) -> ComplexPropertyBudget

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ComplexPropertyBudget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.