Skip to main content

Value

Enum Value 

Source
pub enum Value {
    Null,
    Derived,
    Bool(bool),
    LogicalUnknown,
    Integer(i64),
    Real(f64),
    Text(Arc<str>),
    Binary(Arc<str>),
    Enum(Arc<str>),
    Ref(EntityId),
    List(Vec<Value>),
    Typed {
        type_name: Arc<str>,
        value: Box<Value>,
    },
}
Expand description

One attribute slot in an entity.

This is deliberately a structural representation: it records what the file said, not what it means. Interpretation is the job of the domain crates.

Variants§

§

Null

$ — the attribute is not set.

§

Derived

* — inherited/derived in a supertype; distinct from $.

§

Bool(bool)

.T. / .F.

§

LogicalUnknown

.U. — logical unknown, the third STEP boolean state.

§

Integer(i64)

An integer literal.

§

Real(f64)

A real literal.

§

Text(Arc<str>)

A quoted string, already unescaped to UTF-8.

§

Binary(Arc<str>)

A binary literal ("0123ABC").

§

Enum(Arc<str>)

An unquoted enumeration constant such as .ELEMENT.

§

Ref(EntityId)

A reference to another entity by its in-file id (#42).

§

List(Vec<Value>)

An ordered aggregate: list, set, array or bag.

§

Typed

A typed wrapper such as IFCLENGTHMEASURE(2.5).

Fields

§type_name: Arc<str>

The declared type name, upper-cased as written.

§value: Box<Value>

The wrapped value.

Implementations§

Source§

impl Value

Source

pub fn as_ref_id(&self) -> Option<EntityId>

The referenced entity, if this value is a reference.

Source

pub fn as_bool(&self) -> Option<bool>

The boolean, if this value is .T. or .F..

.U. (logical unknown) returns None: it is a third state, not a missing boolean, and collapsing it to either would lose that.

Source

pub fn as_i64(&self) -> Option<i64>

The integer, if this value is an integer literal.

Does not accept a real: IFC distinguishes IfcInteger from IfcReal, and silently truncating 2.7 to 2 would invent precision the file did not state.

Source

pub fn as_text(&self) -> Option<&str>

The text content, if this is a string.

Source

pub fn as_f64(&self) -> Option<f64>

The numeric value, accepting either integer or real.

IFC files are inconsistent about writing 1 versus 1.0 for the same attribute, so a consumer that insists on one variant will misread real files.

Source

pub fn as_list(&self) -> Option<&[Value]>

The items, if this is an aggregate.

Source

pub fn unwrap_typed(&self) -> &Value

Unwrap a Value::Typed to the value inside, otherwise self.

Callers almost always want the payload; the type name matters only to validation and to writers.

Source

pub fn for_each_ref(&self, f: &mut impl FnMut(EntityId))

Visit every entity reference reachable from this value.

References nest arbitrarily deep inside aggregates, so link rewriting and integrity checks need a recursive walk rather than a shallow scan.

Trait Implementations§

Source§

impl Clone for Value

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 Value

Source§

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

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

impl PartialEq for Value

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
Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.