#[non_exhaustive]pub enum WriteFilter {
None,
BcjX86,
BcjArm,
BcjArm64,
BcjArmThumb,
BcjPpc,
BcjSparc,
BcjIa64,
BcjRiscv,
Bcj2,
Delta {
distance: u8,
},
}Expand description
Pre-compression filter for improving compression of specific data types.
BCJ (Branch/Call/Jump) filters transform executable code addresses from relative to absolute form before compression. This improves compression ratios by 5-15% for executable files because the resulting byte patterns compress better.
The Delta filter computes differences between consecutive samples, improving compression for audio, image, and other structured data.
§Example
use zesven::write::{WriteOptions, WriteFilter};
// Use BCJ x86 filter for compressing Windows/Linux executables
let options = WriteOptions::new().filter(WriteFilter::BcjX86);
// Use Delta filter for audio data (2-byte samples)
let options = WriteOptions::new().filter(WriteFilter::Delta { distance: 2 });Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
None
No filter applied.
BcjX86
BCJ x86 filter for 32-bit and 64-bit x86 executables.
BcjArm
BCJ ARM filter for 32-bit ARM executables.
BcjArm64
BCJ ARM64/AArch64 filter for 64-bit ARM executables.
BcjArmThumb
BCJ ARM Thumb filter for ARM Thumb mode executables.
BcjPpc
BCJ PowerPC filter.
BcjSparc
BCJ SPARC filter.
BcjIa64
BCJ IA-64 (Itanium) filter.
BcjRiscv
BCJ RISC-V filter.
Bcj2
BCJ2 4-stream filter for x86 executables.
BCJ2 splits x86 code into 4 streams (main, call, jump, range) for improved compression. Unlike simple BCJ filters, BCJ2 uses a complex 4-input coder structure.
Note: BCJ2 is only supported in non-solid mode.
Delta
Delta filter for structured data (audio, images).
The distance parameter specifies the sample size in bytes.
Common values:
- 1: byte-level differences
- 2: 16-bit audio samples
- 4: 32-bit values or RGBA pixels
Use WriteFilter::delta() to construct with validation.
Implementations§
Source§impl WriteFilter
impl WriteFilter
Sourcepub fn method_id(&self) -> Option<&'static [u8]>
pub fn method_id(&self) -> Option<&'static [u8]>
Returns the 7z method ID bytes for this filter.
Sourcepub fn is_bcj2(&self) -> bool
pub fn is_bcj2(&self) -> bool
Returns whether this is the BCJ2 filter.
BCJ2 requires special handling as it produces 4 output streams.
Sourcepub fn properties(&self) -> Option<Vec<u8>>
pub fn properties(&self) -> Option<Vec<u8>>
Returns the filter properties to encode in the archive header.
Most BCJ filters have no properties. Delta filter has a 1-byte property
encoding distance - 1 (so distance 1 is stored as 0, distance 255 as 254).
Trait Implementations§
Source§impl Clone for WriteFilter
impl Clone for WriteFilter
Source§fn clone(&self) -> WriteFilter
fn clone(&self) -> WriteFilter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WriteFilter
impl Debug for WriteFilter
Source§impl Default for WriteFilter
impl Default for WriteFilter
Source§fn default() -> WriteFilter
fn default() -> WriteFilter
Source§impl PartialEq for WriteFilter
impl PartialEq for WriteFilter
impl Copy for WriteFilter
impl Eq for WriteFilter
impl StructuralPartialEq for WriteFilter
Auto Trait Implementations§
impl Freeze for WriteFilter
impl RefUnwindSafe for WriteFilter
impl Send for WriteFilter
impl Sync for WriteFilter
impl Unpin for WriteFilter
impl UnwindSafe for WriteFilter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more