Skip to main content

PropertyModel

Struct PropertyModel 

Source
pub struct PropertyModel { /* private fields */ }
Expand description

Hierarchical typed property model (capability groups P1, P2, P4, P5).

Construction is additive (add_category / add_property / insert_property), removal is by subtree, and every mutation validates value/editor compatibility. Default expansion is expanded; collapse any node with set_expanded(id, false). Value edits take either the programmatic path (set_value) or the vetoable user path (request_change → commit_change/denial); every transition is recorded in the ordered PropertyModel::events log.

Equality compares durable state (arena, roots, id counter, collapse set, selection); the transient event log and any pending change are excluded.

Implementations§

Source§

impl PropertyModel

Source

pub fn new() -> Self

Creates an empty model.

Source

pub fn len(&self) -> usize

Number of nodes (categories and properties alike).

Source

pub fn is_empty(&self) -> bool

Whether the model holds no nodes.

Source

pub fn roots(&self) -> &[PropertyId]

Root ids in insertion order.

Source

pub fn get(&self, id: PropertyId) -> Option<&PropertyNode>

Looks a node up by id.

Source

pub fn value(&self, id: PropertyId) -> Option<&PropertyValue>

The value of a property node, when present.

Source

pub fn add_category( &mut self, parent: Option<PropertyId>, label: impl Into<String>, ) -> PropertyResult<PropertyId>

Adds a category group row under parent (or at the root).

Source

pub fn add_property( &mut self, parent: Option<PropertyId>, label: impl Into<String>, editor: PropertyEditor, value: PropertyValue, ) -> PropertyResult<PropertyId>

Adds an editable property under parent (or at the root).

Rejects incompatible value/editor pairs and invalid values.

Source

pub fn insert_property( &mut self, parent: Option<PropertyId>, index: usize, label: impl Into<String>, editor: PropertyEditor, value: PropertyValue, ) -> PropertyResult<PropertyId>

Inserts an editable property at index among the siblings of parent (or among the roots).

Appends when index equals the sibling count; larger indices are the typed InvalidIndex. Rejects incompatible value/editor pairs and invalid values without mutating the model.

Source

pub fn clear(&mut self) -> usize

Drops every node, resolving dependent state first: a staged change is withdrawn, a selection is cleared, and the collapse set resets.

next_id never rewinds, so cleared ids are never reused. Returns how many nodes were removed; Cleared is emitted only for a non-empty model.

Source

pub fn selected(&self) -> Option<PropertyId>

The model’s single selection, when one is set.

Source

pub fn set_selected(&mut self, id: Option<PropertyId>) -> PropertyResult<()>

Moves the selection; None clears it.

Unknown ids are UnknownNode and hidden nodes — or nodes under a hidden ancestor — are Hidden; an unchanged selection emits nothing.

Source

pub fn activate(&mut self, id: PropertyId) -> PropertyResult<()>

Fires the programmatic activation signal (double-click / Enter on the chosen row). Hidden nodes — or nodes under a hidden ancestor — are Hidden, disabled nodes Disabled, unknown ids UnknownNode.

Source

pub fn is_enabled(&self, id: PropertyId) -> bool

Whether the node accepts user edits (unknown ids read as enabled).

Source

pub fn set_enabled( &mut self, id: PropertyId, enabled: bool, ) -> PropertyResult<()>

Enables or disables user edits on a node. Disabling resolves a staged change on that node as Withdrawn.

Source

pub fn is_hidden(&self, id: PropertyId) -> bool

Whether the node is hidden from projections (unknown ids read as visible).

Source

pub fn set_hidden(&mut self, id: PropertyId, hidden: bool) -> PropertyResult<()>

Hides or reveals a node and its subtree. Hiding clears a selection inside the subtree and resolves a staged change there as Withdrawn.

Source

pub fn is_read_only(&self, id: PropertyId) -> bool

Whether both edit paths reject value changes (unknown ids read as editable).

Source

pub fn set_read_only( &mut self, id: PropertyId, read_only: bool, ) -> PropertyResult<()>

Marks a node read-only (or editable again). Marking read-only resolves a staged change on that node as Withdrawn. Read-only is editability state, so setting the flag itself is never blocked.

Source

pub fn ensure_visible(&mut self, id: PropertyId) -> PropertyResult<()>

Expands every ancestor of id (root-most first) so its row can appear in a projection.

Emits one ExpansionChanged per ancestor that actually expands. A node hidden itself — or under a hidden ancestor — is the typed Hidden error, which names the hidden node.

Source

pub fn validation(&self, id: PropertyId) -> Option<&str>

The application-facing validation message for a node, when set.

Source

pub fn set_validation( &mut self, id: PropertyId, message: Option<String>, ) -> PropertyResult<()>

Sets or clears (None) the validation message of a node.

Emits ValidationChanged only when the message actually changes; an unchanged message emits nothing.

Source

pub fn is_modified(&self, id: PropertyId) -> bool

Whether the node carries unsaved changes (unknown ids read as unmodified).

Source

pub fn modified_count(&self) -> usize

How many nodes carry unsaved changes.

Source

pub fn clear_modified(&mut self, id: PropertyId) -> PropertyResult<()>

Clears the dirty marker of one node.

Source

pub fn clear_all_modified(&mut self) -> usize

Clears every dirty marker and reports how many were set.

Source

pub fn request_change( &mut self, id: PropertyId, proposed: PropertyValue, ) -> PropertyResult<ChangeToken>

Stages a user edit and returns its one-shot ChangeToken.

Applies the user-path gates (hidden — the node itself or an ancestor, then disabled, then read-only), the category guard, and the compatibility/value invariants; a rejection mutates nothing and emits nothing. On success the proposal is staged, Changing is emitted, and exactly one decision must follow. A request staged while another is pending resolves the first as Superseded.

Source

pub fn pending_change(&self) -> Option<&PendingChange>

The staged change, when one awaits a decision.

Source

pub fn commit_change(&mut self, token: ChangeToken) -> PropertyResult<()>

Applies a staged change (the Changing → Changed path).

A commit whose value already equals the stored value emits nothing; replaying a decided or unknown token is StaleChange.

Source

pub fn deny_change(&mut self, token: ChangeToken) -> PropertyResult<()>

Vetoes a staged change; the stored value is untouched.

Source

pub fn timeout_change(&mut self, token: ChangeToken) -> PropertyResult<()>

Resolves a staged change as timed out (default deny).

Source

pub fn resolve_change(&mut self, token: ChangeToken) -> PropertyResult<()>

Resolves a staged change with no explicit answer (default deny).

Source

pub fn events(&self) -> &[PropertyEvent]

The ordered event log (oldest first).

Source

pub fn drain_events(&mut self) -> Vec<PropertyEvent>

Takes every recorded event, leaving the log empty.

Source

pub fn clear_events(&mut self)

Discards the recorded events without returning them.

Source

pub fn set_value( &mut self, id: PropertyId, value: PropertyValue, ) -> PropertyResult<()>

Replaces the value of a property node — the documented programmatic edit path.

Applies immediately and is blocked only by read_only (typed ReadOnly); categories, unknown ids, incompatible editors, and invalid values are rejected without mutation. Exactly one Changed event is emitted per real value change and the node is marked modified; a no-op set emits nothing and marks nothing.

Source

pub fn remove(&mut self, id: PropertyId) -> PropertyResult<()>

Removes a node and its whole subtree.

Dependent state resolves before the structural event: a staged change under the subtree is Withdrawn, a selection inside it is cleared (SelectionChanged), and one Removed event then lists every removed id, root first.

Source

pub fn is_expanded(&self, id: PropertyId) -> bool

Whether the node’s children are currently shown (default: shown).

Source

pub fn set_expanded( &mut self, id: PropertyId, expanded: bool, ) -> PropertyResult<()>

Sets the expansion state of a node.

Emits ExpansionChanged only when the state actually changes.

Source

pub fn rows(&self, mode: ProjectionMode) -> Vec<PropertyRow<'_>>

Projects the tree into display rows in document order.

Hidden nodes and their subtrees are omitted in both modes; collapsed subtrees are skipped; CategoryFree omits category rows and surfaces their children at the category’s depth.

Source

pub fn validate(&self) -> PropertyResult<()>

Verifies every structural and value invariant.

This is the deserialization contract: duplicate ids, dangling parents, inconsistent child lists, unreachable nodes, cycles, category values, and invalid value/editor pairs are all rejected.

Trait Implementations§

Source§

impl Clone for PropertyModel

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PropertyModel

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for PropertyModel

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for PropertyModel

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Forget for PropertyModel

§

impl Freeze for PropertyModel

§

impl Move for PropertyModel

§

impl RefUnwindSafe for PropertyModel

§

impl Send for PropertyModel
where RawVecInner: Send, NodeRef<Owned, PropertyId, SetValZST, LeafOrInternal>: Send, BoxRaw<(PropertyId, SetValZST)>: Send,

§

impl Sync for PropertyModel
where RawVecInner: Sync, NodeRef<Owned, PropertyId, SetValZST, LeafOrInternal>: Sync, BoxRaw<(PropertyId, SetValZST)>: Sync,

§

impl Unpin for PropertyModel
where *const u8 is !null: Unpin, *const LeafNode<PropertyId, SetValZST> is !null: Unpin, Box<(PropertyId, SetValZST)>: Unpin,

§

impl UnsafeUnpin for PropertyModel

§

impl UnwindSafe for PropertyModel
where RawVecInner: UnwindSafe, BTreeMap<PropertyId, SetValZST>: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.