pub trait Bmi {
Show 41 methods
// Required methods
fn initialize(&mut self, config_file: &str) -> BmiResult<()>;
fn update(&mut self) -> BmiResult<()>;
fn update_until(&mut self, time: f64) -> BmiResult<()>;
fn finalize(&mut self) -> BmiResult<()>;
fn get_component_name(&self) -> BmiResult<String>;
fn get_input_item_count(&self) -> BmiResult<usize>;
fn get_output_item_count(&self) -> BmiResult<usize>;
fn get_input_var_names(&self) -> BmiResult<Vec<String>>;
fn get_output_var_names(&self) -> BmiResult<Vec<String>>;
fn get_var_grid(&self, name: &str) -> BmiResult<i32>;
fn get_var_type(&self, name: &str) -> BmiResult<String>;
fn get_var_units(&self, name: &str) -> BmiResult<String>;
fn get_var_itemsize(&self, name: &str) -> BmiResult<usize>;
fn get_var_nbytes(&self, name: &str) -> BmiResult<usize>;
fn get_var_location(&self, name: &str) -> BmiResult<Location>;
fn get_current_time(&self) -> BmiResult<f64>;
fn get_start_time(&self) -> BmiResult<f64>;
fn get_end_time(&self) -> BmiResult<f64>;
fn get_time_units(&self) -> BmiResult<String>;
fn get_time_step(&self) -> BmiResult<f64>;
fn get_value(&self, name: &str) -> BmiResult<Values>;
fn get_value_ptr(&self, name: &str) -> BmiResult<RefValues<'_>>;
fn get_value_at_indices(
&self,
name: &str,
indices: &[usize],
) -> BmiResult<Values>;
fn set_value(&mut self, name: &str, src: RefValues<'_>) -> BmiResult<()>;
fn set_value_at_indices(
&mut self,
name: &str,
indices: &[usize],
src: RefValues<'_>,
) -> BmiResult<()>;
fn get_grid_rank(&self, grid: i32) -> BmiResult<usize>;
fn get_grid_size(&self, grid: i32) -> BmiResult<usize>;
fn get_grid_type(&self, grid: i32) -> BmiResult<GridType>;
fn get_grid_shape(&self, grid: i32) -> BmiResult<Vec<usize>>;
fn get_grid_spacing(&self, grid: i32) -> BmiResult<Vec<f64>>;
fn get_grid_origin(&self, grid: i32) -> BmiResult<Vec<f64>>;
fn get_grid_x(&self, grid: i32) -> BmiResult<Vec<f64>>;
fn get_grid_y(&self, grid: i32) -> BmiResult<Vec<f64>>;
fn get_grid_z(&self, grid: i32) -> BmiResult<Vec<f64>>;
fn get_grid_node_count(&self, grid: i32) -> BmiResult<usize>;
fn get_grid_edge_count(&self, grid: i32) -> BmiResult<usize>;
fn get_grid_face_count(&self, grid: i32) -> BmiResult<usize>;
fn get_grid_edge_nodes(&self, grid: i32) -> BmiResult<Vec<usize>>;
fn get_grid_face_edges(&self, grid: i32) -> BmiResult<Vec<usize>>;
fn get_grid_face_nodes(&self, grid: i32) -> BmiResult<Vec<usize>>;
fn get_grid_nodes_per_face(&self, grid: i32) -> BmiResult<Vec<usize>>;
}Expand description
The CSDMS Basic Model Interface 2.0.
Initialize a model before querying or updating it, and finalize it after use.
Variable names follow the model’s advertised input and output names. Grid
identifiers are model-defined; indices and sizes use Rust’s usize.
All methods are fallible and required. Implementations should return errors for invalid names, grid identifiers, indices, types, buffer lengths, lifecycle states, and operations unsupported by their grid or storage representation. Setters must validate their inputs before modifying model storage.
This trait is dyn-compatible, so coupling code can use Box<dyn Bmi>.
Required Methods§
Sourcefn initialize(&mut self, config_file: &str) -> BmiResult<()>
fn initialize(&mut self, config_file: &str) -> BmiResult<()>
Load configuration from config_file and allocate model resources.
An empty path requests the model’s default configuration, if supported.
Sourcefn update_until(&mut self, time: f64) -> BmiResult<()>
fn update_until(&mut self, time: f64) -> BmiResult<()>
Advance to time, expressed in the model’s time units.
Sourcefn get_component_name(&self) -> BmiResult<String>
fn get_component_name(&self) -> BmiResult<String>
Return the model’s human-readable component name.
Sourcefn get_input_item_count(&self) -> BmiResult<usize>
fn get_input_item_count(&self) -> BmiResult<usize>
Return the number of input variables.
Sourcefn get_output_item_count(&self) -> BmiResult<usize>
fn get_output_item_count(&self) -> BmiResult<usize>
Return the number of output variables.
Sourcefn get_input_var_names(&self) -> BmiResult<Vec<String>>
fn get_input_var_names(&self) -> BmiResult<Vec<String>>
Return the names of variables that can be set.
Sourcefn get_output_var_names(&self) -> BmiResult<Vec<String>>
fn get_output_var_names(&self) -> BmiResult<Vec<String>>
Return the names of variables that can be read.
Sourcefn get_var_grid(&self, name: &str) -> BmiResult<i32>
fn get_var_grid(&self, name: &str) -> BmiResult<i32>
Return the grid identifier associated with a variable.
Sourcefn get_var_type(&self, name: &str) -> BmiResult<String>
fn get_var_type(&self, name: &str) -> BmiResult<String>
Return the variable’s native type name (for example, float64).
Sourcefn get_var_units(&self, name: &str) -> BmiResult<String>
fn get_var_units(&self, name: &str) -> BmiResult<String>
Return the variable’s units, preferably using UDUNITS conventions.
Sourcefn get_var_itemsize(&self, name: &str) -> BmiResult<usize>
fn get_var_itemsize(&self, name: &str) -> BmiResult<usize>
Return the size of one variable element in bytes.
Sourcefn get_var_nbytes(&self, name: &str) -> BmiResult<usize>
fn get_var_nbytes(&self, name: &str) -> BmiResult<usize>
Return the total size of a variable’s values in bytes.
Sourcefn get_var_location(&self, name: &str) -> BmiResult<Location>
fn get_var_location(&self, name: &str) -> BmiResult<Location>
Return whether the variable is defined on nodes, edges, or faces.
Sourcefn get_current_time(&self) -> BmiResult<f64>
fn get_current_time(&self) -> BmiResult<f64>
Return the current simulation time.
Sourcefn get_start_time(&self) -> BmiResult<f64>
fn get_start_time(&self) -> BmiResult<f64>
Return the simulation’s start time.
Sourcefn get_end_time(&self) -> BmiResult<f64>
fn get_end_time(&self) -> BmiResult<f64>
Return the simulation’s end time.
Sourcefn get_time_units(&self) -> BmiResult<String>
fn get_time_units(&self) -> BmiResult<String>
Return the units used by every time query and update_until.
Sourcefn get_time_step(&self) -> BmiResult<f64>
fn get_time_step(&self) -> BmiResult<f64>
Return the model’s current time-step duration.
Sourcefn get_value(&self, name: &str) -> BmiResult<Values>
fn get_value(&self, name: &str) -> BmiResult<Values>
Return an owned copy of all values, preserving their numeric type.
Sourcefn get_value_ptr(&self, name: &str) -> BmiResult<RefValues<'_>>
fn get_value_ptr(&self, name: &str) -> BmiResult<RefValues<'_>>
Borrow the model’s storage without copying it.
The slice cannot outlive the model borrow. Rust prevents mutable calls,
including update, set_value, and finalize, while it is still in use.
Changes must go through the setters; no mutable raw pointer is exposed.
Sourcefn get_value_at_indices(
&self,
name: &str,
indices: &[usize],
) -> BmiResult<Values>
fn get_value_at_indices( &self, name: &str, indices: &[usize], ) -> BmiResult<Values>
Copy values at zero-based flattened indices, in the requested order. Repeated indices repeat values; an empty index slice returns no values.
Sourcefn set_value(&mut self, name: &str, src: RefValues<'_>) -> BmiResult<()>
fn set_value(&mut self, name: &str, src: RefValues<'_>) -> BmiResult<()>
Copy src into a variable. Its type and length must match the variable.
Sourcefn set_value_at_indices(
&mut self,
name: &str,
indices: &[usize],
src: RefValues<'_>,
) -> BmiResult<()>
fn set_value_at_indices( &mut self, name: &str, indices: &[usize], src: RefValues<'_>, ) -> BmiResult<()>
Copy values into zero-based flattened indices.
src must match the variable’s type and have one value per index.
Sourcefn get_grid_rank(&self, grid: i32) -> BmiResult<usize>
fn get_grid_rank(&self, grid: i32) -> BmiResult<usize>
Return the number of spatial dimensions.
Sourcefn get_grid_size(&self, grid: i32) -> BmiResult<usize>
fn get_grid_size(&self, grid: i32) -> BmiResult<usize>
Return the total number of grid nodes.
Sourcefn get_grid_type(&self, grid: i32) -> BmiResult<GridType>
fn get_grid_type(&self, grid: i32) -> BmiResult<GridType>
Return the grid’s topology and geometry category.
Sourcefn get_grid_shape(&self, grid: i32) -> BmiResult<Vec<usize>>
fn get_grid_shape(&self, grid: i32) -> BmiResult<Vec<usize>>
Return the node count along each axis, ordered slowest to fastest (z, y, x). The returned length equals the grid rank.
Sourcefn get_grid_spacing(&self, grid: i32) -> BmiResult<Vec<f64>>
fn get_grid_spacing(&self, grid: i32) -> BmiResult<Vec<f64>>
Return uniform axis spacing, ordered as get_grid_shape.
Sourcefn get_grid_origin(&self, grid: i32) -> BmiResult<Vec<f64>>
fn get_grid_origin(&self, grid: i32) -> BmiResult<Vec<f64>>
Return the grid origin, ordered as get_grid_shape.
Sourcefn get_grid_x(&self, grid: i32) -> BmiResult<Vec<f64>>
fn get_grid_x(&self, grid: i32) -> BmiResult<Vec<f64>>
Return x coordinates: axis coordinates for rectilinear grids, otherwise per node.
Sourcefn get_grid_y(&self, grid: i32) -> BmiResult<Vec<f64>>
fn get_grid_y(&self, grid: i32) -> BmiResult<Vec<f64>>
Return y coordinates: axis coordinates for rectilinear grids, otherwise per node.
Sourcefn get_grid_z(&self, grid: i32) -> BmiResult<Vec<f64>>
fn get_grid_z(&self, grid: i32) -> BmiResult<Vec<f64>>
Return z coordinates: axis coordinates for rectilinear grids, otherwise per node.
Sourcefn get_grid_node_count(&self, grid: i32) -> BmiResult<usize>
fn get_grid_node_count(&self, grid: i32) -> BmiResult<usize>
Return the number of nodes in an unstructured grid.
Sourcefn get_grid_edge_count(&self, grid: i32) -> BmiResult<usize>
fn get_grid_edge_count(&self, grid: i32) -> BmiResult<usize>
Return the number of edges in an unstructured grid.
Sourcefn get_grid_face_count(&self, grid: i32) -> BmiResult<usize>
fn get_grid_face_count(&self, grid: i32) -> BmiResult<usize>
Return the number of faces in an unstructured grid.
Sourcefn get_grid_edge_nodes(&self, grid: i32) -> BmiResult<Vec<usize>>
fn get_grid_edge_nodes(&self, grid: i32) -> BmiResult<Vec<usize>>
Return flattened node pairs for edges, with two indices per edge.
Sourcefn get_grid_face_edges(&self, grid: i32) -> BmiResult<Vec<usize>>
fn get_grid_face_edges(&self, grid: i32) -> BmiResult<Vec<usize>>
Return flattened edge indices for faces, grouped in face order.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".