pub struct AttributeDescriptor {
pub key: String,
pub label: String,
pub kind: OptionKind,
pub quantity: Option<String>,
pub editable: bool,
pub references: Vec<String>,
}Expand description
Description of one attribute an application may display for elements of a kind (spec §4.4).
Reuses the option-descriptor value vocabulary (OptionKind, spec
§3.2.1) and is advisory in exactly that sense: it tells a generic UI
what to show; it is not the validation authority, and an engine remains
free to hold data no schema advertises.
Fields§
§key: StringField name in the element’s attribute data. Stable per kind; renaming one is a break, like a block id.
label: StringHuman-facing name.
kind: OptionKindValue shape and bounds.
quantity: Option<String>Key of the physical quantity the value carries (spec §5), or None
for dimensionless or textual attributes.
editable: boolWhether a write to this attribute may be offered (spec §4.5.1).
Advisory: the write is the authority, and an engine refuses one it will not accept whether or not this said so. It exists so a surface can offer an input rather than offer one and be refused, which teaches the user the same thing one interaction later.
This says the attribute can be written, not that a particular element can be: an element that carries no value for the key has nothing to change, and offering an input there would invite creating a value the model never held.
Defaulted on the wire so a schema written before the editing contract deserialises, offering nothing rather than everything.
references: Vec<String>The kind ids whose elements this attribute may name (spec §4.5.1.1), empty for a value that is not a reference.
Without them a reference is indistinguishable from free text, and an application can only offer a box to type a name into — where the names are the model’s own and a typo produces a reference to nothing.
A list because a reference is not always to one kind: a drainage subcatchment discharges to a conveyance node or to another subcatchment. It must be the complete set an application may offer — a subset is worse than none, since a list that looks complete is read as complete.
Not a foreign key: this layer defines no referential integrity and does not require the named element to exist. What happens to a reference when its target is removed is the engine’s rule, expressed through its removal (§4.5.4).
Trait Implementations§
Source§impl Clone for AttributeDescriptor
impl Clone for AttributeDescriptor
Source§fn clone(&self) -> AttributeDescriptor
fn clone(&self) -> AttributeDescriptor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more