pub struct FractalCompressor;Expand description
Fractal compression engine.
Implementations§
Source§impl FractalCompressor
impl FractalCompressor
pub fn new() -> Self
Sourcepub fn compress(
&self,
coord: &FiveDimCoord,
chaos_seed: &[u8; 32],
target_dims: usize,
) -> Result<IfsCodebook, PrivacyError>
pub fn compress( &self, coord: &FiveDimCoord, chaos_seed: &[u8; 32], target_dims: usize, ) -> Result<IfsCodebook, PrivacyError>
Compress a 5D manifold vertex using IFS.
Identifies self-similar patterns via barnsley-style collage theorem. Chaos perturbation modulates transformation coefficients.
Sourcepub fn compress_bytes(
&self,
data: &[u8],
) -> Result<CompressedBlob, PrivacyError>
pub fn compress_bytes( &self, data: &[u8], ) -> Result<CompressedBlob, PrivacyError>
Losslessly compress byte data with DEFLATE (RFC 1951), falling back to storing it verbatim when that does not make it smaller.
This is not fractal compression and does not use the IFS machinery above — see the
module doc comment for why. The round-trip through
decompress_bytes is exact.
The fallback is what keeps the output from growing: no algorithm compresses every
input, so incompressible data (already-compressed bytes, ciphertext, high-entropy
keys — much of what this crate handles) is stored as-is and flagged in
CompressedBlob::stored.
Sourcepub fn decompress(
&self,
codebook: &IfsCodebook,
) -> Result<FiveDimCoord, PrivacyError>
pub fn decompress( &self, codebook: &IfsCodebook, ) -> Result<FiveDimCoord, PrivacyError>
Decompress an IFS codebook back to a 5D coordinate.
Iterates the IFS attractor for 100 steps.
Sourcepub fn decompress_bytes(blob: &CompressedBlob) -> Result<Vec<u8>, PrivacyError>
pub fn decompress_bytes(blob: &CompressedBlob) -> Result<Vec<u8>, PrivacyError>
Recover the exact bytes a CompressedBlob was built from.
Inflates the DEFLATE stream, or returns the stored bytes when
CompressedBlob::stored is set, then checks both the recovered length and its
SHA-256 against what the blob recorded. A mismatch is reported as an error rather
than returned to the caller.
Sourcepub fn compress_and_verify(
&self,
data: &[u8],
) -> Result<(CompressedBlob, Vec<u8>), PrivacyError>
pub fn compress_and_verify( &self, data: &[u8], ) -> Result<(CompressedBlob, Vec<u8>), PrivacyError>
Compress data and immediately prove the round-trip recovers it exactly.
Unlike the earlier version of this method, this can genuinely fail: the compression path is real, so a defect in it surfaces here rather than being masked by the input having been stored verbatim.
Returns (blob, decompressed), where decompressed == data.
Sourcepub fn compression_ratio(original_dims: usize, codebook: &IfsCodebook) -> f64
pub fn compression_ratio(original_dims: usize, codebook: &IfsCodebook) -> f64
Storage ratio for the IFS path: original coordinate size over the size of the transforms that replace it.
This describes dimension reduction on a FiveDimCoord, not byte compression. For
that, use CompressedBlob::ratio.