Struct ruststep::ast::SubSuperRecord [−][src]
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
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
fn deserialize_struct<V>(
self,
name: &'static str,
fields: &'static [&'static str],
visitor: V
) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
fn deserialize_struct<V>(
self,
name: &'static str,
fields: &'static [&'static str],
visitor: V
) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
fn deserialize_enum<V>(
self,
name: &'static str,
variants: &'static [&'static str],
visitor: V
) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
fn deserialize_enum<V>(
self,
name: &'static str,
variants: &'static [&'static str],
visitor: V
) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for SubSuperRecord
impl Send for SubSuperRecord
impl Sync for SubSuperRecord
impl Unpin for SubSuperRecord
impl UnwindSafe for SubSuperRecord
Blanket Implementations
Mutably borrows from an owned value. Read more