pub struct DeltaEncoder { /* private fields */ }Expand description
Delta encoder using bsdiff
Provides delta compression and decompression with intelligent decision logic, with optional media-aware configuration.
Implementations§
Source§impl DeltaEncoder
impl DeltaEncoder
Sourcepub fn with_thresholds(
similarity_threshold: f64,
min_space_savings: f64,
) -> Self
pub fn with_thresholds( similarity_threshold: f64, min_space_savings: f64, ) -> Self
Create a delta encoder with custom thresholds
Sourcepub fn encode_with_depth(
&self,
base: &[u8],
target: &[u8],
current_chain_depth: u32,
) -> CompressionResult<(Vec<u8>, bool)>
pub fn encode_with_depth( &self, base: &[u8], target: &[u8], current_chain_depth: u32, ) -> CompressionResult<(Vec<u8>, bool)>
Encode a delta between base and target with chain depth tracking
Returns (delta_data, should_use_delta)
§Arguments
base- Base version datatarget- Target version datacurrent_chain_depth- Current depth in the delta chain
§Returns
Tuple of (delta_data, should_use_delta). If should_use_delta is false, delta_data contains the full target data instead.
§Delta Chain Depth
When the chain depth exceeds max_chain_depth, the encoder will return
the full object instead of creating another delta. This prevents
excessively long delta chains that can hurt decompression performance.
Sourcepub fn decode_chain(
&self,
versions: &[(Vec<u8>, bool)],
) -> CompressionResult<Vec<u8>>
pub fn decode_chain( &self, versions: &[(Vec<u8>, bool)], ) -> CompressionResult<Vec<u8>>
Sourcepub fn max_chain_depth(&self) -> u32
pub fn max_chain_depth(&self) -> u32
Get the maximum chain depth setting
Sourcepub fn set_max_chain_depth(&mut self, depth: u32)
pub fn set_max_chain_depth(&mut self, depth: u32)
Set the maximum chain depth
When encoding deltas, if the current chain depth reaches this value, the encoder will store the full object instead of creating another delta.
§Arguments
depth- Maximum allowed chain depth (typically 50-100)
§Example
use mediagit_compression::delta::DeltaEncoder;
let mut encoder = DeltaEncoder::new();
encoder.set_max_chain_depth(75);
assert_eq!(encoder.max_chain_depth(), 75);