Enum ruststep::ast::Parameter [−][src]
pub enum Parameter {
Typed {
name: String,
ty: Box<Parameter>,
},
Integer(i64),
Real(f64),
String(String),
Enumeration(String),
List(Vec<Parameter>),
RValue(RValue),
NotProvided,
Omitted,
}
Expand description
Primitive value type in STEP data
Parse
use nom::Finish;
use ruststep::{parser::exchange, ast::Parameter};
// Real number
let (residual, p) = exchange::parameter("1.0").finish().unwrap();
assert_eq!(residual, "");
assert_eq!(p, Parameter::real(1.0));
// String
let (residual, p) = exchange::parameter("'ruststep'").finish().unwrap();
assert_eq!(residual, "");
assert_eq!(p, Parameter::string("ruststep"));
// non-uniform list
let (residual, p) = exchange::parameter("('ruststep', 1.0)").finish().unwrap();
assert_eq!(residual, "");
assert_eq!(p, Parameter::from_iter(&[Parameter::string("ruststep"), Parameter::real(1.0)]));
// inline typed struct
let (residual, p) = exchange::parameter("FILE_NAME('ruststep')").finish().unwrap();
assert_eq!(residual, "");
assert!(matches!(p, Parameter::Typed { .. }));
Inline struct or list can be nested, i.e. Parameter
can be a tree.
use nom::Finish;
use ruststep::{parser::exchange, ast::Parameter};
let (residual, p) = exchange::parameter("B((1.0, A((2.0, 3.0))))")
.finish()
.unwrap();
assert_eq!(residual, "");
// A((2.0, 3.0))
let a = Parameter::Typed {
name: "A".to_string(),
ty: Box::new(Parameter::from_iter(&[Parameter::real(2.0), Parameter::real(3.0)])),
};
// B((1.0, a))
let b = Parameter::Typed {
name: "B".to_string(),
ty: Box::new(Parameter::from_iter(&[Parameter::real(1.0), a])),
};
assert_eq!(p, b);
FromIterator
Create a list as Parameter::List
from Iterator<Item=Parameter>
or Iterator<Item=&Parameter>
.
use ruststep::ast::Parameter;
let p: Parameter = [Parameter::real(1.0), Parameter::real(2.0)]
.iter()
.collect();
assert!(matches!(p, Parameter::List(_)));
Variants
Inline Typed struct
Integer(i64)
Signed integer
Tuple Fields of Integer
0: i64
Real(f64)
Real number
Tuple Fields of Real
0: f64
String(String)
string literal
Tuple Fields of String
0: String
Enumeration(String)
Enumeration defined in EXPRESS schema, like .TRUE.
Tuple Fields of Enumeration
0: String
List of other parameters
RValue(RValue)
A reference to entity or value
Tuple Fields of RValue
0: RValue
The special token dollar sign ($
) is used to represent
an object whose value is not provided in the exchange structure.
Omitted parameter denoted by *
Implementations
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
type Deserializer = Self
type Deserializer = Self
The type of the deserializer being converted into.
Convert this value into a deserializer.
Auto Trait Implementations
impl RefUnwindSafe for Parameter
impl UnwindSafe for Parameter
Blanket Implementations
Mutably borrows from an owned value. Read more