use std::cmp::Ordering;
use crate::entry::{File, FileLocation};
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ExtractEntry {
file: File,
location: FileLocation,
}
impl ExtractEntry {
#[must_use]
#[inline]
pub const fn new(file: File, location: FileLocation) -> Self {
Self { file, location }
}
#[must_use]
#[inline]
pub const fn location_index(&self) -> u32 {
self.file.location()
}
#[must_use]
#[inline]
pub const fn file(&self) -> &File {
&self.file
}
#[must_use]
#[inline]
pub const fn file_location(&self) -> &FileLocation {
&self.location
}
}
impl PartialOrd for ExtractEntry {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for ExtractEntry {
fn cmp(&self, other: &Self) -> Ordering {
self.file_location()
.file()
.offset()
.cmp(&other.file_location().file().offset())
.then_with(|| self.location_index().cmp(&other.location_index()))
}
}