ReferenceFmus

Struct ReferenceFmus 

Source
pub struct ReferenceFmus { /* private fields */ }
Expand description

A Rust interface to the Modelica Reference-FMUs, downloaded as an archive using fetch_data

This struct provides access to the official Modelica Reference FMUs for testing and validation purposes. It automatically downloads the FMU archive from the official GitHub repository and provides methods to access individual FMUs.

§Examples

use fmi_test_data::ReferenceFmus;
use fmi::traits::FmiImport;

let mut reference_fmus = ReferenceFmus::new()?;

// Load a specific FMU
let fmu: fmi::fmi3::import::Fmi3Import = reference_fmus.get_reference_fmu("BouncingBall")?;

// List all available FMUs
let available_fmus = reference_fmus.list_available_fmus()?;
println!("Available FMUs: {:?}", available_fmus);

Implementations§

Source§

impl ReferenceFmus

Source

pub fn new() -> Result<Self>

Fetch the released Modelica Reference-FMUs file

Downloads and caches the Reference FMUs archive from the official GitHub repository. The archive is automatically verified using SHA256 checksums.

§Errors

Returns an error if:

  • The download fails
  • The file cannot be opened
  • The ZIP archive is corrupted
Source

pub fn get_reference_fmu<Imp: FmiImport>(&mut self, name: &str) -> Result<Imp>

Get a reference FMU as an import instance

Loads a specific FMU from the archive and returns it as the requested import type. The FMU version is automatically determined by the import type.

§Arguments
  • name - The name of the FMU to load (e.g., “BouncingBall”)
§Examples
let mut reference_fmus = ReferenceFmus::new()?;

// Load FMI 2.0 version
let fmu: fmi::fmi2::import::Fmi2Import = reference_fmus.get_reference_fmu("BouncingBall")?;

// Load FMI 3.0 version  
let fmu: fmi::fmi3::import::Fmi3Import = reference_fmus.get_reference_fmu("BouncingBall")?;
Source

pub fn extract_reference_fmu( &mut self, name: &str, version: MajorVersion, ) -> Result<NamedTempFile>

Extract a reference FMU from the reference archive into a temporary file

This method extracts an FMU to a temporary file on disk, which can be useful when you need to pass a file path to other tools or libraries.

§Arguments
  • name - The name of the FMU to extract
  • version - The FMI major version to extract
§Returns

A NamedTempFile containing the extracted FMU. The file will be automatically deleted when the returned value is dropped.

Source

pub fn list_available_fmus(&mut self) -> Result<Vec<String>>

Get a list of all available FMU files in the archive

Returns a sorted list of all FMU names available in the Reference FMUs archive. These names can be used with get_reference_fmu() or extract_reference_fmu().

§Examples
let mut reference_fmus = ReferenceFmus::new()?;
let fmus = reference_fmus.list_available_fmus()?;

for fmu_name in &fmus {
    println!("Available: {}", fmu_name);
}
Source

pub fn version() -> &'static str

Get the Reference FMU version being used

Returns the version string of the Reference FMUs package that this crate is configured to use.

Trait Implementations§

Source§

impl Debug for ReferenceFmus

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> ErasedDestructor for T
where T: 'static,