1use crate::MajorVersion;
4
5pub trait DefaultExperiment {
6 fn start_time(&self) -> Option<f64>;
7 fn stop_time(&self) -> Option<f64>;
8 fn tolerance(&self) -> Option<f64>;
9 fn step_size(&self) -> Option<f64>;
10}
11
12pub trait FmiModelDescription: Sized {
14 fn model_name(&self) -> &str;
16
17 fn version_string(&self) -> &str;
19
20 fn version(&self) -> Result<semver::Version, crate::Error> {
22 lenient_semver::parse(self.version_string()).map_err(|e| e.owned().into())
23 }
24
25 fn major_version(&self) -> Result<MajorVersion, crate::Error> {
27 match self.version()? {
28 v if v.major == 1 => Ok(MajorVersion::FMI1),
29 v if v.major == 2 => Ok(MajorVersion::FMI2),
30 v if v.major == 3 => Ok(MajorVersion::FMI3),
31 v => panic!("Invalid version {}", v.major),
32 }
33 }
34
35 fn deserialize(xml: &str) -> Result<Self, crate::Error>;
37
38 fn serialize(&self) -> Result<String, crate::Error>;
40}
41
42pub trait FmiInterfaceType: Sized {
44 fn model_identifier(&self) -> &str;
46 fn needs_execution_tool(&self) -> Option<bool>;
48 fn can_be_instantiated_only_once_per_process(&self) -> Option<bool>;
50 fn can_get_and_set_fmu_state(&self) -> Option<bool>;
52 fn can_serialize_fmu_state(&self) -> Option<bool>;
54 fn provides_directional_derivatives(&self) -> Option<bool>;
56 fn provides_adjoint_derivatives(&self) -> Option<bool>;
59 fn provides_per_element_dependencies(&self) -> Option<bool>;
62}