Skip to content

Commit 9114556

Browse files
committed
Inline err_out_of_bounds function
1 parent 35c6265 commit 9114556

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

crates/iceberg/src/puffin/metadata.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,6 @@ impl FileMetadata {
177177
file_read.read(start..end).await
178178
}
179179

180-
fn err_out_of_bounds<T>() -> Result<T> {
181-
Err(Error::new(
182-
ErrorKind::DataInvalid,
183-
"Index range is out of bounds.",
184-
))
185-
}
186-
187180
fn decode_flags(footer_bytes: &[u8]) -> Result<HashSet<Flag>> {
188181
let mut flags = HashSet::new();
189182
for byte_number in 0..FileMetadata::FOOTER_STRUCT_FLAGS_LENGTH {
@@ -193,7 +186,10 @@ impl FileMetadata {
193186
+ usize::from(byte_number);
194187

195188
let mut flag_byte = match footer_bytes.get(byte_offset) {
196-
None => FileMetadata::err_out_of_bounds(),
189+
None => Err(Error::new(
190+
ErrorKind::DataInvalid,
191+
"Index range is out of bounds.",
192+
)),
197193
Some(byte) => Ok(*byte),
198194
}?;
199195
let mut bit_number = 0;
@@ -234,7 +230,10 @@ impl FileMetadata {
234230
let end_offset =
235231
usize::from(FileMetadata::MAGIC_LENGTH) + usize::try_from(footer_payload_length)?;
236232
let footer_payload_bytes = match footer_bytes.get(start_offset..end_offset) {
237-
None => FileMetadata::err_out_of_bounds(),
233+
None => Err(Error::new(
234+
ErrorKind::DataInvalid,
235+
"Index range is out of bounds.",
236+
)),
238237
Some(data) => Ok(data),
239238
}?;
240239
let decompressed_footer_payload_bytes =

0 commit comments

Comments
 (0)