imodfile 0.1.0

A pure-Rust IMOD model file decoder/encoder — binary & ASCII, with Python bindings
Documentation
//! General-purpose storage (Istore).
//!
//! This module provides convenience functions for working with the `Istore`
//! type that is defined in `model.rs`.

pub use crate::model::{Istore, IstoreItem};

impl Istore {
    /// Add a floating-point value at the given index.
    pub fn add_float(&mut self, index: i32, value: f32) {
        self.items.push(IstoreItem {
            flags: 0,
            index,
            value_f: value,
            value_i: 0,
        });
    }

    /// Add an integer value at the given index.
    pub fn add_int(&mut self, index: i32, value: i32) {
        self.items.push(IstoreItem {
            flags: 0,
            index,
            value_f: 0.0,
            value_i: value,
        });
    }

    /// Number of items in the store.
    pub fn len(&self) -> usize {
        self.items.len()
    }

    /// Returns `true` if the store is empty.
    pub fn is_empty(&self) -> bool {
        self.items.is_empty()
    }
}