snappy-framing-0.1.2: Snappy Framing Format in Haskell

Copyright(c) 2013 Kim Altintop <kim.altintop@gmail.com>
LicenseThis Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. A copy of the MPL can be found in the LICENSE file or you can obtain it at http://mozilla.org/MPL/2.0/.
MaintainerKim Altintop <kim.altintop@gmail.com>
Stabilityexperimental
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Codec.Compression.Snappy.Framing

Contents

Description

 
Synopsis

Exported Types

Encoding and Decoding

encode :: ByteString -> (Chunk, Maybe ByteString) Source #

Encode a lazy ByteString into a Chunk

If the input is longer than minCompressible bytes, the resulting chunk is Compressed otherwise Uncompressed. If the input size exceeds maxUncompressed bytes, the leftover input is returned in a Just.

encode' :: ByteString -> (Chunk, Maybe ByteString) Source #

Encode a strict ByteString into a Chunk

If the input is longer than minCompressible bytes, the resulting chunk is Compressed otherwise Uncompressed. If the input size exceeds maxUncompressed bytes, the leftover input is returned in a Just.

decodeM Source #

Arguments

:: Monad m 
=> m (Maybe ByteString)

And action that will be run to provide input. If it returns Nothing it is assumed no more input is available.

-> m (Either DecodeError Chunk, Maybe ByteString)

Either a parse error or a Chunk, along with leftovers if any.

Decode drawing input from the given monadic action as needed

Utility functions

checksum :: ByteString -> Checksum Source #

Compute a masked CRC32C checksum of the input

streamIdentifier :: ByteString Source #

Yield a stream identifier (start-of-stream marker)

verify :: Chunk -> Maybe Chunk Source #

Verify a Chunk

Returns Nothing if the input is an Unskippable chunk, or the checksum verification fails (if the input is a Compressed or Uncompressed chunk). Otherwise, the input Chunk is returned in a Just. Note that Compressed chunks are decompressed into Uncompressed chunks on the fly.