diff options
author | cc <cc@localhost> | 2025-08-20 21:13:36 -0700 |
---|---|---|
committer | cc <cc@localhost> | 2025-08-20 21:13:36 -0700 |
commit | 41b4532661e52e07517faec8c0f9a93a33e3f105 (patch) | |
tree | 2f633cd6498331f31fdbdf133e9dec4651c24d01 /src | |
parent | b903f5a5e9250691bab6644200b244a0da961219 (diff) |
File output bindings
Diffstat (limited to 'src')
-rw-r--r-- | src/label_formats/label_format.rs | 4 | ||||
-rw-r--r-- | src/label_formats/large_label_format.rs | 4 | ||||
-rw-r--r-- | src/lib.rs | 11 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/label_formats/label_format.rs b/src/label_formats/label_format.rs index b2373f5..afbb2ad 100644 --- a/src/label_formats/label_format.rs +++ b/src/label_formats/label_format.rs @@ -172,6 +172,10 @@ impl LabelFormat { x.ierode(); x } + + pub fn dump(&self, filename: &str) -> Result<(), std::io::Error> { + crate::binfile::dump_u16_vec(filename, self.buffer.clone()) + } } #[cfg(test)] diff --git a/src/label_formats/large_label_format.rs b/src/label_formats/large_label_format.rs index 6ad19b3..a6128c0 100644 --- a/src/label_formats/large_label_format.rs +++ b/src/label_formats/large_label_format.rs @@ -38,4 +38,8 @@ impl LargeLabelFormat { height: self.height, }; } + + pub fn dump(&self, filename: &str) -> Result<(), std::io::Error> { + crate::binfile::dump_u32_vec(filename, self.buffer.clone()) + } } @@ -82,9 +82,9 @@ mod tests { fn tiff_data_dump_test() { tiff::ignore_warnings(); if let Some(large_label_format) = tiff::to_large_labels(TEST_IMAGE_PATH) { - println!("{:?}", large_label_format); - let data = large_label_format.buffer; - binfile::dump_u32_vec(TEST_OUTPUT_PATH, data).expect("File output error"); + if let Err(_) = large_label_format.dump(TEST_LABEL_OUTPUT_PATH) { + assert!(false); + } } else { assert!(false); } @@ -95,8 +95,9 @@ mod tests { tiff::ignore_warnings(); if let Some(large_label_format) = tiff::to_large_labels(TEST_IMAGE_PATH) { let compressed_format = large_label_format.compress(); - let data = compressed_format.buffer; - binfile::dump_u16_vec(TEST_LABEL_OUTPUT_PATH, data).expect("File output error"); + if let Err(_) = compressed_format.dump(TEST_LABEL_OUTPUT_PATH) { + assert!(false); + } } else { assert!(false); } |