| Portability | non-portable (GHC extensions) |
|---|---|
| Stability | experimental |
| Maintainer | Kim Altintop <kim.altintop@gmail.com> |
| Safe Haskell | None |
Codec.Compression.Snappy.Framing
Description
- type Checksum = Word32
- data Chunk
- = StreamIdentifier
- | Compressed !Checksum !ByteString
- | Uncompressed !Checksum !ByteString
- | Skippable !Word8
- | Unskippable !Word8
- type DecodeError = (ByteOffset, String)
- encode :: ByteString -> (Chunk, Maybe ByteString)
- encode' :: ByteString -> (Chunk, Maybe ByteString)
- decode :: ByteString -> (Either DecodeError Chunk, Maybe ByteString)
- decode' :: ByteString -> (Either DecodeError Chunk, Maybe ByteString)
- decodeVerify :: ByteString -> (Either DecodeError Chunk, Maybe ByteString)
- decodeVerify' :: ByteString -> (Either DecodeError Chunk, Maybe ByteString)
- decodeM :: Monad m => m (Maybe ByteString) -> m (Either DecodeError Chunk, Maybe ByteString)
- decodeVerifyM :: Monad m => m (Maybe ByteString) -> m (Either DecodeError Chunk, Maybe ByteString)
- checksum :: ByteString -> Checksum
- streamIdentifier :: ByteString
- verify :: Chunk -> Maybe Chunk
Exported Types
Constructors
| StreamIdentifier | |
| Compressed !Checksum !ByteString | |
| Uncompressed !Checksum !ByteString | |
| Skippable !Word8 | |
| Unskippable !Word8 |
type DecodeError = (ByteOffset, String)Source
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.
decode :: ByteString -> (Either DecodeError Chunk, Maybe ByteString)Source
Decode a lazy ByteString into a Chunk
decode' :: ByteString -> (Either DecodeError Chunk, Maybe ByteString)Source
Decode a strict ByteString into a Chunk
decodeVerify :: ByteString -> (Either DecodeError Chunk, Maybe ByteString)Source
Decode a lazy ByteString into a Chunk and verify the result
decodeVerify' :: ByteString -> (Either DecodeError Chunk, Maybe ByteString)Source
Decode a strict ByteString into a Chunk and verify the result
Arguments
| :: Monad m | |
| => m (Maybe ByteString) | And action that will be run to provide input. If it returns
|
| -> m (Either DecodeError Chunk, Maybe ByteString) | Either a parse error or a |
Decode drawing input from the given monadic action as needed
decodeVerifyM :: Monad m => m (Maybe ByteString) -> m (Either DecodeError Chunk, Maybe ByteString)Source
Utility functions
checksum :: ByteString -> ChecksumSource
Compute a masked CRC32C checksum of the input
streamIdentifier :: ByteStringSource
Yield a stream identifier (start-of-stream marker)
verify :: Chunk -> Maybe ChunkSource
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.