format: keep dataset_fill_value_in's &[u8] signature
Making dataset_fill_value_in generic over Storage broke callers that pass an array (`include_bytes!`): a generic parameter does not unsize-coerce `&[u8; N]`. It takes &[u8] again, as before this branch, and wraps the new dataset_fill_value_from_storage(&dyn Storage, ..). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -111,17 +111,24 @@ pub fn dataset_fill_value(messages: &[HeaderMessage]) -> Result<Option<Vec<u8>>,
|
||||
/// 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<S: crate::storage::Storage + ?Sized>(
|
||||
file_data: &S,
|
||||
pub fn dataset_fill_value_in(
|
||||
file_data: &[u8],
|
||||
messages: &[HeaderMessage],
|
||||
offset_size: u8,
|
||||
length_size: u8,
|
||||
) -> Result<Option<Vec<u8>>, 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<Option<Vec<u8>>, 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);
|
||||
|
||||
Reference in New Issue
Block a user