Skip to content

Commit

Permalink
Merge pull request #40 from tgross35/extra-debug-impls
Browse files Browse the repository at this point in the history
Add `Debug` implementation for `CompoundFile`
  • Loading branch information
mdsteele authored Aug 4, 2023
2 parents 0267125 + ad697cc commit 5c5279d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/internal/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ impl<F> Allocator<F> {
self.sectors.version()
}

pub fn inner(&self) -> &F {
self.sectors.inner()
}

pub fn sector_len(&self) -> usize {
self.sectors.sector_len()
}
Expand Down
4 changes: 4 additions & 0 deletions src/internal/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ impl<F> Directory<F> {
self.allocator.version()
}

pub fn inner(&self) -> &F {
self.allocator.inner()
}

pub fn sector_len(&self) -> usize {
self.allocator.sector_len()
}
Expand Down
4 changes: 4 additions & 0 deletions src/internal/minialloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ impl<F> MiniAllocator<F> {
self.directory.version()
}

pub fn inner(&self) -> &F {
self.directory.inner()
}

pub fn next_mini_sector(&self, sector_id: u32) -> io::Result<u32> {
let index = sector_id as usize;
if index >= self.minifat.len() {
Expand Down
4 changes: 4 additions & 0 deletions src/internal/sector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ impl<F> Sectors<F> {
pub fn into_inner(self) -> F {
self.inner
}

pub fn inner(&self) -> &F {
&self.inner
}
}

impl<F: Seek> Sectors<F> {
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#![warn(missing_docs)]

use std::cell::{Ref, RefCell, RefMut};
use std::fmt;
use std::fs;
use std::io::{self, Read, Seek, SeekFrom, Write};
use std::mem::size_of;
Expand Down Expand Up @@ -964,6 +965,12 @@ impl<F: Read + Write + Seek> CompoundFile<F> {
}
}

impl<F: fmt::Debug> fmt::Debug for CompoundFile<F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("CompoundFile").field(self.minialloc().inner()).finish()
}
}

//===========================================================================//

#[cfg(test)]
Expand Down

0 comments on commit 5c5279d

Please sign in to comment.