pub enum Value {
Boolean(bool),
Integer(i64),
Float(Real),
Text(Box<str>),
Enum(EnumValueId),
Reference(Mrid),
Compound(Box<Compound>),
}Expand description
The value of a single attribute occurrence.
CIM datatypes (Resistance, ActivePower, …) serialize as their underlying
primitive, so they are represented by Value::Float and friends; the unit and
multiplier are schema constants recoverable from the attribute’s
DatatypeDef.
Variants§
Boolean(bool)
Integer(i64)
Float(Real)
Text(Box<str>)
Strings, dates, times and durations; CIM keeps these in their lexical form.
Enum(EnumValueId)
An enumeration literal.
Reference(Mrid)
A reference to another object, by mRID.
Compound(Box<Compound>)
An inline structured value with no identity of its own.
Boxed: compounds are rare, and inline they would triple every value’s size.
Implementations§
Source§impl Value
impl Value
pub fn as_bool(&self) -> Option<bool>
pub fn as_i64(&self) -> Option<i64>
pub fn as_f64(&self) -> Option<f64>
pub fn as_str(&self) -> Option<&str>
pub fn as_enum(&self) -> Option<EnumValueId>
pub fn as_reference(&self) -> Option<&Mrid>
pub fn as_compound(&self) -> Option<&Compound>
Sourcepub fn to_lexical(&self) -> Option<String>
pub fn to_lexical(&self) -> Option<String>
Render in the lexical form CIM/XML uses for element text.
Only meaningful for values serialized as text; enumerations, references and
compounds have their own serializations and return None.
Sourcepub fn to_lexical_as(&self, prim: Primitive) -> Option<String>
pub fn to_lexical_as(&self, prim: Primitive) -> Option<String>
Render in the lexical form prim permits.
xsd:decimal has no exponent notation, so a Decimal is written out in full;
a Float uses exponent form where plain decimal would be long.
Sourcepub fn fits(&self, prim: Primitive) -> bool
pub fn fits(&self, prim: Primitive) -> bool
Whether this value can serve an attribute declared as prim.
Shared by validate and the RDF writer. An integer serves a
float or decimal, and text serves dates, times and durations (kept lexically).
Sourcepub fn shape(&self) -> &'static str
pub fn shape(&self) -> &'static str
A one-word description of what this value is, for diagnostics.
Sourcepub fn parse_primitive(
prim: Primitive,
text: &str,
) -> Result<Value, ParseValueError>
pub fn parse_primitive( prim: Primitive, text: &str, ) -> Result<Value, ParseValueError>
Parse element text according to the attribute’s primitive type.