-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | LZ4 compression for ByteStrings
--   
--   High level bindings to the LZ4 compression library.
--   
--   Currently based on lz4 r119. C sources are included and no external
--   dependencies are needed other than <tt>cereal</tt>.
@package lz4
@version 0.2.3.1


-- | This module provides a high level <tt>ByteString</tt> interface to the
--   lz4 library. More information about lz4 can be found here:
--   <a>http://code.google.com/p/lz4/</a>.
--   
--   This module prefixes the buffer that is compressed with the
--   uncompressed length (as lz4 can't recover this information itself.) It
--   also has this property: all functions when called with an empty string
--   return <tt>Just Data.ByteString.empty</tt>
module Codec.Compression.LZ4

-- | Compresses the input <tt>ByteString</tt>.
--   
--   Will return <a>Nothing</a> if the compression fails. Otherwise,
--   returns <tt>Just xs</tt> with the compressed string (and additionally,
--   if <tt>xs == empty</tt> then <tt>compress empty == Just empty</tt>.)
compress :: ByteString -> Maybe ByteString

-- | Decompress the input <tt>ByteString</tt>.
decompress :: ByteString -> Maybe ByteString

-- | Compress the input <tt>ByteString</tt> as much as possible, but comes
--   with a massive speed drop in compression. Decompression is faster
--   however and can be done with <a>decompress</a>.
--   
--   Will return <a>Nothing</a> if the compression fails. Otherwise,
--   returns <tt>Just xs</tt> with the compressed string (and additionally,
--   if <tt>xs == empty</tt> then <tt>compressHC empty == Just empty</tt>.)
compressHC :: ByteString -> Maybe ByteString

-- | Essentially defined as:
--   
--   <pre>
--   compressPlusHC xs = compress xs &gt;&gt;= compressHC
--   </pre>
--   
--   This is an experimental interface. After regular compression, due to
--   output encoding, things like relative offsets in the compression
--   buffer or artifacts from number encoding can end up the same in the
--   output buffer for often repeated data. Therefore, further savings are
--   possible in the input buffer by compressing again. lz4 even in high
--   compression mode will quickly ignore already-compressed data and
--   remain quite fast. Thus, this interface is designed to give a better
--   compression/speed tradeoff than <a>compressHC</a>: it doesn't compress
--   as well, but is nowhere near as slow. Some context:
--   <a>http://www.reddit.com/r/programming/comments/vyu7r/compressing_log_files_twice_improves_ratio/c58svj3?context=3</a>
--   
--   Must be decompressed with <a>decompressPlusHC</a>.
--   
--   Will return <a>Nothing</a> if the compression fails. Otherwise,
--   returns <tt>Just xs</tt> with the compressed string (and additionally,
--   if <tt>xs == empty</tt> then <tt>compressPlusHC empty == Just
--   empty</tt>.)
compressPlusHC :: ByteString -> Maybe ByteString

-- | Decompress a string compressed with <a>compressPlusHC</a>. Essentially
--   defined as:
--   
--   <pre>
--   decompressPlusHC xs = decompress xs &gt;&gt;= decompress
--   </pre>
decompressPlusHC :: ByteString -> Maybe ByteString

-- | Compresses a string.
c_LZ4_compress :: Ptr CChar -> Ptr Word8 -> CInt -> IO CInt

-- | Compresses a string with very high compression.
c_LZ4_compressHC :: Ptr CChar -> Ptr Word8 -> CInt -> IO CInt

-- | Decompresses a string. Works for both <a>c_LZ4_compress</a> and
--   <a>c_LZ4_compressHC</a>.
c_LZ4_uncompress :: Ptr CChar -> Ptr Word8 -> CInt -> IO CInt

-- | Worst case compression bounds on an input string.
c_LZ4_compressBound :: CInt -> CInt
