feat: add get_value_mut_ptr method to bmi_rs::Bmi trait
#14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@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
ngenjust output variables, overget_value_ptr. This PR introduces a new optionalBmi::get_value_mut_ptrtrait member function to address this limitation. Additionally,Bmi::get_value_mut_ptris now called by the wrapped bmi-cget_value_ptrfunction pointer. In more verbose terms:This crate’s bmi-c ffi bindings call a
Bmisget_value_mut_ptrmethod when the bmi-cget_value_ptrfunction pointer is called. Code calling theBmiinstance should use this method to read or write data to a variable the model chooses to expose by pointer. The code calling theBmiinstance must be aware of the lifetime guarantees of the returned pointer. It’s recommended thatBmiinstances that implement this method provide aSAFETYcomment documenting the lifetime guarantees of variables exposed by their implementation.closes #13
Added
get_value_mut_ptrmethod tobmi_rs::Bmitrait; analog of bmi-c'sget_value_ptr.Default returns
Err(BmiNotImplementedError).Changed
get_value_ptrwrapper callsbmi_rs::Bmi::get_value_mut_ptrinstead of always returningBMI_FAILURE.