Skip to content

Commit

Permalink
improve support for gnf pack/unpacking
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan-rsm-McKenzie committed Feb 13, 2024
1 parent eec81f1 commit 8ee76b8
Show file tree
Hide file tree
Showing 3 changed files with 801 additions and 125 deletions.
29 changes: 28 additions & 1 deletion src/fo4/chunk.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
containers::CompressableBytes,
derive,
fo4::{ArchiveOptions, CompressionFormat, CompressionLevel, Error, Result},
fo4::{ArchiveOptions, CompressionFormat, CompressionLevel, Error, FileWriteOptions, Result},
};
use core::ops::RangeInclusive;
use flate2::{
Expand Down Expand Up @@ -52,6 +52,18 @@ impl From<&ArchiveOptions> for CompressionOptionsBuilder {
}
}

impl From<FileWriteOptions> for CompressionOptionsBuilder {
fn from(value: FileWriteOptions) -> Self {
(&value).into()
}
}

impl From<&FileWriteOptions> for CompressionOptionsBuilder {
fn from(value: &FileWriteOptions) -> Self {
Self(value.into())
}
}

/// Common parameters to configure how chunks are compressed.
///
/// ```rust
Expand Down Expand Up @@ -118,6 +130,21 @@ impl From<&ArchiveOptions> for CompressionOptions {
}
}

impl From<FileWriteOptions> for CompressionOptions {
fn from(value: FileWriteOptions) -> Self {
(&value).into()
}
}

impl From<&FileWriteOptions> for CompressionOptions {
fn from(value: &FileWriteOptions) -> Self {
Self {
compression_format: value.compression_format(),
..Default::default()
}
}
}

/// Represents a chunk of a file within the FO4 virtual filesystem.
#[derive(Clone, Debug, Default)]
pub struct Chunk<'bytes> {
Expand Down
Loading

0 comments on commit 8ee76b8

Please sign in to comment.