Skip to content

Commit

Permalink
CHORE: added type annotations to tdfblobs
Browse files Browse the repository at this point in the history
  • Loading branch information
sander-willems-bruker committed Jun 14, 2024
1 parent 1f221c3 commit 22448c0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/io/readers/common/tdf_blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ pub struct TdfBlob {
}

impl TdfBlob {
#[inline(always)]
pub fn get(&self, index: usize) -> u32 {
debug_assert!(index < self.len());
Self::concatenate_bytes(
self.bytes[index],
self.bytes[index + self.len()],
Expand Down Expand Up @@ -48,7 +50,7 @@ pub struct TdfBlobReader {

impl TdfBlobReader {
pub fn new(file_name: impl AsRef<Path>) -> Result<Self, TdfBlobError> {
let path = file_name.as_ref().to_path_buf();
let path: PathBuf = file_name.as_ref().to_path_buf();
let file: File = File::open(&path)?;
let mmap: Mmap = unsafe { Mmap::map(&file)? };
Ok(Self {
Expand All @@ -59,7 +61,7 @@ impl TdfBlobReader {
}

pub fn get_blob(&self, offset: usize) -> Result<TdfBlob, TdfBlobError> {
let offset = self.get_offset(offset)?;
let offset: usize = self.get_offset(offset)?;
let byte_count: usize = self.get_byte_count(offset)?;
let compressed_bytes: &[u8] =
self.get_compressed_bytes(offset, byte_count);
Expand Down Expand Up @@ -189,7 +191,7 @@ pub trait TdfBlobParsable {

#[derive(Debug, thiserror::Error)]
pub enum TdfBlobError {
#[error("Cannot read or mmap file: {0}")]
#[error("Cannot read or mmap file {0}")]
IO(#[from] io::Error),
#[error("Index {0} is invalid for file {1}")]
Index(usize, PathBuf),
Expand Down

0 comments on commit 22448c0

Please sign in to comment.