Struct ruststep::ast::SubSuperRecord[][src]

pub struct SubSuperRecord(pub Vec<Record>);
Expand description

A set of Record mapping to complex entity instance, e.g. (A(1) B(2.0) C("3"))

FromStr

use ruststep::ast::*;
use std::str::FromStr;

let record = SubSuperRecord::from_str("(A(1, 2) B(3, 4))").unwrap();
assert_eq!(
    record,
    SubSuperRecord(vec![
        Record {
            name: "A".to_string(),
            parameter: vec![
                Parameter::Integer(1),
                Parameter::Integer(2)
            ].into(),
        },
        Record {
            name: "B".to_string(),
            parameter: vec![
                Parameter::Integer(3),
                Parameter::Integer(4)
            ].into(),
        }
    ])
)

Deserialize as a map

Similar to Record, SubSuperRecord can be deserialized as a “map”:

use std::{str::FromStr, collections::HashMap};
use ruststep::ast::*;
use serde::Deserialize;

let p = SubSuperRecord::from_str("(A(1, 2) B(3, 4))").unwrap();

// Map can be deserialize as a hashmap
assert_eq!(
    HashMap::<String, Vec<i32>>::deserialize(&p).unwrap(),
    maplit::hashmap! {
        "A".to_string() => vec![1, 2],
        "B".to_string() => vec![3, 4],
    }
);

// Map in serde can be interpreted as Rust field
#[derive(Debug, Clone, PartialEq, Deserialize)]
struct X {
    #[serde(rename = "A")]
    a: Vec<i32>,
    #[serde(rename = "B")]
    b: Vec<i32>,
}
assert_eq!(
    X::deserialize(&p).unwrap(),
    X {
        a: vec![1, 2],
        b: vec![3, 4]
    }
);

External mapping to complex entity instance

As discussed in Record for internal mapping,

ENTITY person;
  name: STRING;
END_ENTITY;

ENTITY employee SUBTYPE OF (person);
  pay: INTEGER;
END_ENTITY;

ENTITY student SUBTYPE OF (person);
  school_name: STRING;
END_ENTITY;

The instance of person may have three partial complex entity. External mapping has different looks in exchange structure:

#3 = (PERSON('Hitori Goto') EMPLOYEE(10));
#4 = (PERSON('Ikuno Kita') STUDENT('Shuka));
#5 = (PERSON('Nizika Iziti') EMPLOYEE(15) STUDENT('Simokitazawa'))

Each components enclosed by () corresponds to a partial entity instance, which consists of fields declared in its entity definition.

#5 = (PERSON('Nizika Iziti') EMPLOYEE(15) STUDENT('Simokitazawa'))
             ▲                        ▲           ▲
             │                        │           └─ school_name in student
             │                        └─ pay in employee
             └─ name in person

The detail of external mapping is defined in 12.2.5.3 “External mapping” of ISO-10303-21.

SubSuperRecord is not self-describing because EXPRESS does not defines memory layout of complex entities.

Tuple Fields

0: Vec<Record>

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The error type that can be returned if some error occurs during deserialization. Read more

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more

Hint that the Deserialize type is expecting a bool value.

Hint that the Deserialize type is expecting an i8 value.

Hint that the Deserialize type is expecting an i16 value.

Hint that the Deserialize type is expecting an i32 value.

Hint that the Deserialize type is expecting an i64 value.

Hint that the Deserialize type is expecting an i128 value. Read more

Hint that the Deserialize type is expecting a u8 value.

Hint that the Deserialize type is expecting a u16 value.

Hint that the Deserialize type is expecting a u32 value.

Hint that the Deserialize type is expecting a u64 value.

Hint that the Deserialize type is expecting an u128 value. Read more

Hint that the Deserialize type is expecting a f32 value.

Hint that the Deserialize type is expecting a f64 value.

Hint that the Deserialize type is expecting a char value.

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more

Hint that the Deserialize type is expecting an optional value. Read more

Hint that the Deserialize type is expecting a unit value.

Hint that the Deserialize type is expecting a unit struct with a particular name. Read more

Hint that the Deserialize type is expecting a newtype struct with a particular name. Read more

Hint that the Deserialize type is expecting a sequence of values.

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data. Read more

Hint that the Deserialize type is expecting a struct with a particular name and fields. Read more

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields. Read more

Hint that the Deserialize type is expecting a map of key-value pairs.

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants. Read more

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant. Read more

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more

Creates a value from an iterator. Read more

Creates a value from an iterator. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.