Skip to content

Conversation

@aaraney
Copy link
Owner

@aaraney aaraney commented Dec 1, 2025

@JoshCu brought up an issue in the bmi-c bindings where a bmi driver program may require bmi-c models expose their variables, in the case of ngen just output variables, over get_value_ptr. This PR introduces a new optional Bmi::get_value_mut_ptr trait member function to address this limitation. Additionally, Bmi::get_value_mut_ptr is now called by the wrapped bmi-c get_value_ptr function pointer. In more verbose terms:

This crate’s bmi-c ffi bindings call a Bmis get_value_mut_ptr method when the bmi-c get_value_ptr function pointer is called. Code calling the Bmi instance should use this method to read or write data to a variable the model chooses to expose by pointer. The code calling the Bmi instance must be aware of the lifetime guarantees of the returned pointer. It’s recommended that Bmi instances that implement this method provide a SAFETY comment documenting the lifetime guarantees of variables exposed by their implementation.

closes #13

Added

  • Unsafe get_value_mut_ptr method to bmi_rs::Bmi trait; analog of bmi-c's get_value_ptr.
    Default returns Err(BmiNotImplementedError).

Changed

  • bmi-c ffi get_value_ptr wrapper calls bmi_rs::Bmi::get_value_mut_ptr instead of always returning BMI_FAILURE.

@aaraney aaraney added the enhancement New feature or request label Dec 1, 2025
@aaraney aaraney self-assigned this Dec 1, 2025
@aaraney
Copy link
Owner Author

aaraney commented Dec 1, 2025

@JoshCu, can you try out this branch when you have a chance?

@aaraney aaraney force-pushed the feat-get_value_ptr branch from e251495 to 313ee0f Compare December 2, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants