All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lame.gzip.Compressor.scala Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2009-2019 Lightbend Inc. 
 */

package lame.gzip

import akka.util.ByteString

/**
  *
  * A stateful object representing ongoing compression.
  */
trait Compressor {

  /**
    * Compresses the given input and returns compressed data. The implementation
    * can and will choose to buffer output data to improve compression. Use
    * `flush` or `compressAndFlush` to make sure that all input data has been
    * compressed and pending output data has been returned.
    */
  def compress(input: ByteString): ByteString

  /**
    * Flushes any output data and returns the currently remaining compressed data.
    */
  def flush(): ByteString

  /**
    * Closes this compressed stream and return the remaining compressed data. After
    * calling this method, this Compressor cannot be used any further.
    */
  def finish(): ByteString

  /** Combines `compress` + `flush` */
  def compressAndFlush(input: ByteString): ByteString

  /** Combines `compress` + `finish` */
  def compressAndFinish(input: ByteString): ByteString

  /** Make sure any resources have been released */
  def close(): Unit

  def needsInput: Boolean
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy