Skip to main content

FpZipCompressor

Struct FpZipCompressor 

Source
pub struct FpZipCompressor { /* private fields */ }
Expand description

Builder for configuring and executing fpzip compression.

Provides a fluent API for setting dimensions and precision before compressing. Defaults to 1D (ny=1, nz=1, nf=1) at full precision (lossless).

§Example

use fpzip_rs::{FpZipCompressor, decompress_f32};

let data: Vec<f32> = (0..64).map(|i| i as f32).collect();
let compressed = FpZipCompressor::new(4)
    .ny(4)
    .nz(4)
    .compress_f32(&data)
    .unwrap();

let decompressed = decompress_f32(&compressed).unwrap();
assert_eq!(data, decompressed);

Implementations§

Source§

impl FpZipCompressor

Source

pub fn new(nx: u32) -> Self

Creates a new compressor for an array with X dimension nx.

Source

pub fn ny(self, ny: u32) -> Self

Sets the Y dimension (default: 1).

Source

pub fn nz(self, nz: u32) -> Self

Sets the Z dimension (default: 1).

Source

pub fn nf(self, nf: u32) -> Self

Sets the number of fields / 4th dimension (default: 1).

Source

pub fn prec(self, prec: u32) -> Self

Sets the bit precision for lossy compression.

  • 0 or full type width (32 for float, 64 for double) = lossless.
  • For float: valid range is 2..=32.
  • For double: valid range is 4..=64 (even values only).
  • Lower precision gives better compression ratios at the cost of accuracy.
Source

pub fn compress_f32(&self, data: &[f32]) -> Result<Vec<u8>>

Compresses a float slice with the configured dimensions and precision.

Source

pub fn compress_f64(&self, data: &[f64]) -> Result<Vec<u8>>

Compresses a double slice with the configured dimensions and precision.

Source

pub fn compress_f32_into(&self, data: &[f32], dest: &mut [u8]) -> Result<usize>

Compresses a float slice into a pre-allocated buffer.

Source

pub fn compress_f64_into(&self, data: &[f64], dest: &mut [u8]) -> Result<usize>

Compresses a double slice into a pre-allocated buffer.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.