- replace anyhow with custom error type
This commit is contained in:
+13
-23
@@ -1,5 +1,6 @@
|
||||
extern crate link_cplusplus;
|
||||
|
||||
pub mod error;
|
||||
mod functions;
|
||||
mod handle;
|
||||
mod interop;
|
||||
@@ -9,27 +10,24 @@ pub mod sys;
|
||||
pub use functions::*;
|
||||
pub use handle::*;
|
||||
pub use interop::*;
|
||||
pub use misc::{Dimension, LibCZIApiError, PixelType, RawDataType};
|
||||
pub use misc::{Dimension, PixelType, RawDataType};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::handle::{CziReader, InputStream};
|
||||
use crate::interop::{LibCZIBuildInformation, ReaderOpenInfo};
|
||||
use crate::misc::Dimension;
|
||||
use anyhow::{Error, Result};
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn test_read_shape() -> Result<()> {
|
||||
fn test_read_shape() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let path = env::home_dir()
|
||||
.unwrap()
|
||||
.join("code/rust/ndbioimage/tests/files/Experiment-2029.czi");
|
||||
assert!(path.exists());
|
||||
let czi = CziReader::create()?;
|
||||
let stream = InputStream::create_from_file_utf8(
|
||||
path.to_str().ok_or(Error::msg("cannot into str"))?,
|
||||
)?;
|
||||
let stream = InputStream::create_from_file_utf8(path.to_string_lossy().as_ref())?;
|
||||
let open_info = ReaderOpenInfo::new(&stream);
|
||||
czi.open(open_info)?;
|
||||
println!("pyramid statistics: {:?}", czi.get_pyramid_statistics()?);
|
||||
@@ -49,15 +47,13 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_read_bytes() -> Result<()> {
|
||||
fn test_read_bytes() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let path = env::home_dir()
|
||||
.unwrap()
|
||||
.join("code/rust/ndbioimage/tests/files/Experiment-2029.czi");
|
||||
assert!(path.exists());
|
||||
let czi = CziReader::create()?;
|
||||
let stream = InputStream::create_from_file_utf8(
|
||||
path.to_str().ok_or(Error::msg("cannot into str"))?,
|
||||
)?;
|
||||
let stream = InputStream::create_from_file_utf8(path.to_string_lossy().as_ref())?;
|
||||
let open_info = ReaderOpenInfo::new(&stream);
|
||||
czi.open(open_info)?;
|
||||
let sub_block = czi.read_sub_block(0)?;
|
||||
@@ -75,15 +71,13 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_libczi_xml() -> Result<()> {
|
||||
fn test_libczi_xml() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let path = env::home_dir()
|
||||
.unwrap()
|
||||
.join("code/rust/ndbioimage/tests/files/Experiment-2029.czi");
|
||||
assert!(path.exists());
|
||||
let czi = CziReader::create()?;
|
||||
let stream = InputStream::create_from_file_utf8(
|
||||
path.to_str().ok_or(Error::msg("cannot into str"))?,
|
||||
)?;
|
||||
let stream = InputStream::create_from_file_utf8(path.to_string_lossy().as_ref())?;
|
||||
let open_info = ReaderOpenInfo::new(&stream);
|
||||
czi.open(open_info)?;
|
||||
let metadata_segment = czi.get_metadata_segment()?;
|
||||
@@ -94,13 +88,11 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_libczi_pyramid_statistics() -> Result<()> {
|
||||
fn test_libczi_pyramid_statistics() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let path = PathBuf::from("test-files/Experiment-2029.czi");
|
||||
assert!(path.exists());
|
||||
let czi = CziReader::create()?;
|
||||
let stream = InputStream::create_from_file_utf8(
|
||||
path.to_str().ok_or(Error::msg("cannot into str"))?,
|
||||
)?;
|
||||
let stream = InputStream::create_from_file_utf8(path.to_string_lossy().as_ref())?;
|
||||
let open_info = ReaderOpenInfo::new(&stream);
|
||||
czi.open(open_info)?;
|
||||
let s = czi.get_pyramid_statistics()?;
|
||||
@@ -109,13 +101,11 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_libczi_document_info() -> Result<()> {
|
||||
fn test_libczi_document_info() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let path = PathBuf::from("test-files/Experiment-2029.czi");
|
||||
assert!(path.exists());
|
||||
let czi = CziReader::create()?;
|
||||
let stream = InputStream::create_from_file_utf8(
|
||||
path.to_str().ok_or(Error::msg("cannot into str"))?,
|
||||
)?;
|
||||
let stream = InputStream::create_from_file_utf8(path.to_string_lossy().as_ref())?;
|
||||
let open_info = ReaderOpenInfo::new(&stream);
|
||||
czi.open(open_info)?;
|
||||
let metadata_segment = czi.get_metadata_segment()?;
|
||||
@@ -129,7 +119,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lib_czi_build_information() -> Result<()> {
|
||||
fn test_lib_czi_build_information() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let build_info = LibCZIBuildInformation::get()?;
|
||||
println!(
|
||||
"compiler information: {:?}",
|
||||
|
||||
Reference in New Issue
Block a user