rconan / matio-rs

Rust MATIO bindings
MIT License
0 stars 3 forks source link

thread 'main' panicked at 'not implemented' #4

Open jklizarraga opened 1 year ago

jklizarraga commented 1 year ago

Hi!

I was trying to use your library to access a simple .mat file containing a single Matlab struct with 8 fields, and I got the error below after executing the following code:

use matio_rs::{MatFile, Mat};

fn main() {
    let file_path = "/foo/thematlabfile.mat";
    let var_name  = "the_matlab_struct";

    let mat_file_read = match MatFile::load(file_path){
        Ok(file_read) => file_read,
        Err(error) => panic!("Panic while opening file, details: {:?}", error),
    };

    println!("{:?}", mat_file_read.info());  // This works => Matlab var.: "the_matlab_struct" with dims: [1, 1]

    let mat_variable: Mat = match mat_file_read.var(var_name){
        Ok(variable) => variable,
        Err(error) => panic!("Panic while extracting variable, details: {:?}", error),
    };

}

Do you have any idea of what the problem may be?

Many thanks in advance for your help.

Cheers

J.

PS: In case it helps, the data types of the 8 fields of the Matlab struct are:

  1. 2D matrix of double
  2. 2D matrix of double
  3. String
  4. Double
  5. Double
  6. Double
  7. String
  8. String

Error

thread 'main' panicked at 'not implemented', /Users/foo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matio-rs-1.3.1/src/datatype.rs:101:1
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
   3: matio_rs::datatype::MatType::from_ptr
             at /Users/foo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matio-rs-1.3.1/src/datatype.rs:86:26
   4: matio_rs::mat::Mat::from_ptr
             at /Users/foo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matio-rs-1.3.1/src/mat.rs:136:12
   5: matio_rs::mat::Mat::from_ptr
             at /Users/foo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matio-rs-1.3.1/src/mat.rs:165:23
   6: matio_rs::mat::<impl matio_rs::matfile::MatFile>::read
             at /Users/foo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matio-rs-1.3.1/src/mat.rs:33:13
   7: matio_rs::mat::<impl matio_rs::matfile::MatFileRead>::var
             at /Users/foo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matio-rs-1.3.1/src/mat.rs:76:9
   8: some_code::main
             at ./src/main.rs:14:39
   9: core::ops::function::FnOnce::call_once
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
rconan commented 1 year ago

The problem comes from the String in the Matlab structure, matio-rs is not handling reading and writing Strings yet

jklizarraga commented 1 year ago

Thanks for you help!