Function create_zstd_encoder

Source
fn create_zstd_encoder(
    file: File,
    compression_level: &ZstdCompressionLevel,
    threads: &ZstdThreads,
    settings: &CompressionSettings,
) -> Result<Encoder<'static, File>, Error>
Expand description

Creates and configures an [Encoder].

Uses a dedicated compression_level and amount of threads to construct and configure an encoder for zstd compression. The settings are merely used for additional context in cases of error.

ยงErrors

Returns an error if

  • the encoder cannot be created using the file and compression_level,
  • the encoder cannot be configured to use checksums at the end of each frame,
  • the amount of physical CPU cores can not be turned into a u32,
  • or multithreading can not be enabled based on the provided threads settings.