diff --git a/crates/clawhdf5-format/src/fill_value.rs b/crates/clawhdf5-format/src/fill_value.rs index 88cbc3f..6ab3460 100644 --- a/crates/clawhdf5-format/src/fill_value.rs +++ b/crates/clawhdf5-format/src/fill_value.rs @@ -111,17 +111,24 @@ pub fn dataset_fill_value(messages: &[HeaderMessage]) -> Result>, /// fill value message to where it lives: another object header, or the /// file's shared-message (SOHM) heap, as libhdf5 writes it when the file has /// a SOHM index for fill values. -/// -/// `file_data` is any [`Storage`](crate::storage::Storage): the file as a -/// `&[u8]`, or a backend that serves it by range. (The trait is not -/// imported here: its `len` would shadow the slice method in this module.) -pub fn dataset_fill_value_in( - file_data: &S, +pub fn dataset_fill_value_in( + file_data: &[u8], + messages: &[HeaderMessage], + offset_size: u8, + length_size: u8, +) -> Result>, FormatError> { + dataset_fill_value_from_storage(&file_data, messages, offset_size, length_size) +} + +/// [`dataset_fill_value_in`] with the file behind any +/// [`Storage`](crate::storage::Storage). (The trait is not imported here: +/// its `len` would shadow the slice method in this module.) +pub fn dataset_fill_value_from_storage( + file: &dyn crate::storage::Storage, messages: &[HeaderMessage], offset_size: u8, length_size: u8, ) -> Result>, FormatError> { - let file: &dyn crate::storage::Storage = &file_data; fill_value_from(messages, |msg| { crate::shared_message::message_data_with_sohm_in(file, msg, offset_size, length_size) .map(|data| data.into_owned()) @@ -472,7 +479,7 @@ mod tests { .count(); let want = dataset_fill_value_in(file, &h.messages, os, ls); assert_eq!(want, Ok(Some((-7i32).to_le_bytes().to_vec()))); - let got = dataset_fill_value_in(&storage, &h.messages, os, ls); + let got = dataset_fill_value_from_storage(&storage, &h.messages, os, ls); assert_eq!(got, want, "{}", child.name); } assert!(shared >= 2); diff --git a/crates/clawhdf5-format/tests/storage_equivalence.rs b/crates/clawhdf5-format/tests/storage_equivalence.rs index a046ffb..ada6274 100644 --- a/crates/clawhdf5-format/tests/storage_equivalence.rs +++ b/crates/clawhdf5-format/tests/storage_equivalence.rs @@ -44,7 +44,7 @@ use clawhdf5_format::error::FormatError; use clawhdf5_format::extensible_array::{ ExtensibleArrayHeader, read_extensible_array_chunks, read_extensible_array_chunks_in, }; -use clawhdf5_format::fill_value::dataset_fill_value_in; +use clawhdf5_format::fill_value::{dataset_fill_value_from_storage, dataset_fill_value_in}; use clawhdf5_format::fixed_array::{ FixedArrayHeader, read_fixed_array_chunks, read_fixed_array_chunks_in, }; @@ -189,7 +189,7 @@ impl Walk<'_> { self.same( "fill value", &want, - &dataset_fill_value_in(self.storage, &header.messages, os, ls), + &dataset_fill_value_from_storage(self.st(), &header.messages, os, ls), ); for msg in &header.messages {