Skip to content

Commit

Permalink
🚚 Rename ReadEntryContainer to EntryContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanTsune committed Nov 13, 2023
1 parent 2301f01 commit 84e73c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/src/archive/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ impl<R: Read> Read for EntryReader<R> {
}

#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub(crate) enum ReadEntryContainer {
pub(crate) enum EntryContainer {
Solid(SolidReadEntry),
NonSolid(ReadEntry),
Regular(ReadEntry),
}

impl TryFrom<ChunkEntry> for ReadEntryContainer {
impl TryFrom<ChunkEntry> for EntryContainer {
type Error = io::Error;
fn try_from(entry: ChunkEntry) -> Result<Self, Self::Error> {
if let Some(first_chunk) = entry.0.first() {
match first_chunk.ty {
ChunkType::SHED => Ok(Self::Solid(SolidReadEntry::try_from(entry)?)),
ChunkType::FHED => Ok(Self::NonSolid(ReadEntry::try_from(entry)?)),
ChunkType::FHED => Ok(Self::Regular(ReadEntry::try_from(entry)?)),
_ => Err(io::Error::new(io::ErrorKind::InvalidData, "Invalid entry")),
}
} else {
Expand Down
12 changes: 6 additions & 6 deletions lib/src/archive/read.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
archive::{Archive, ArchiveHeader, ChunkEntry, ReadEntry, ReadEntryContainer, PNA_HEADER},
archive::{Archive, ArchiveHeader, ChunkEntry, EntryContainer, ReadEntry, PNA_HEADER},
chunk::{Chunk, ChunkReader, ChunkType, RawChunk},
};
use std::{
Expand Down Expand Up @@ -103,8 +103,8 @@ impl<R: Read> Archive<R> {
loop {
let entry = self.read_entry()?;
return match entry {
Some(ReadEntryContainer::NonSolid(entry)) => Ok(Some(entry)),
Some(ReadEntryContainer::Solid(_)) => continue,
Some(EntryContainer::Regular(entry)) => Ok(Some(entry)),
Some(EntryContainer::Solid(_)) => continue,
None => Ok(None),
};
}
Expand All @@ -119,7 +119,7 @@ impl<R: Read> Archive<R> {
/// # Errors
///
/// Returns an error if an I/O error occurs while reading from the archive.
pub(crate) fn read_entry(&mut self) -> io::Result<Option<ReadEntryContainer>> {
pub(crate) fn read_entry(&mut self) -> io::Result<Option<EntryContainer>> {
let entry = self.next_raw_item()?;
match entry {
Some(entry) => Ok(Some(entry.try_into()?)),
Expand Down Expand Up @@ -223,8 +223,8 @@ impl<'r, R: Read> Iterator for Entries<'r, R> {
}
let entry = self.reader.read_entry();
match entry {
Ok(Some(ReadEntryContainer::NonSolid(entry))) => Some(Ok(entry)),
Ok(Some(ReadEntryContainer::Solid(entry))) => match &self.password {
Ok(Some(EntryContainer::Regular(entry))) => Some(Ok(entry)),
Ok(Some(EntryContainer::Solid(entry))) => match &self.password {
Some(password) => {
let entries = entry.entries(password.as_deref());
match entries {
Expand Down

0 comments on commit 84e73c6

Please sign in to comment.