Skip to main content

AttributeDescriptor

Struct AttributeDescriptor 

Source
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: String

Field name in the element’s attribute data. Stable per kind; renaming one is a break, like a block id.

§label: String

Human-facing name.

§kind: OptionKind

Value shape and bounds.

§quantity: Option<String>

Key of the physical quantity the value carries (spec §5), or None for dimensionless or textual attributes.

§editable: bool

Whether 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

Source§

fn clone(&self) -> AttributeDescriptor

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 AttributeDescriptor

Source§

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

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

impl<'de> Deserialize<'de> for AttributeDescriptor

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for AttributeDescriptor

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for AttributeDescriptor

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AttributeDescriptor

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.